-1

I am performing a method call that places any objects found in the background into an NSArray object called "objects".

When I NSLog the counts property of "objects" it tells me that the array contains 1 object which is correct.

When I NSLog the NSArray object called "objects" it prints out the following:

(
"<PFUser:nzyjeVFgjU:(null)> {\n    email = \"hahshshs@aol.com\";\n    username = hzhjsshhsppppp;\n    verificationCode = 6449;\n}"
)

Here is my problem. I need to create an if statement that takes another value I already have and compares it to the 4 digit number that verificationCode is equal to eg. Above in the code it says "verificationCode = 6449"

I am basically trying to compare a 4 digit code that I already have to the verificationCode that is contained in this single NSArray object.

I know how to write if statements, but i have no idea how to specifically focus on "verificationCode = 6449" since it is just text inside of a string.

I have been trying to figure out a way to do this for an hour now so any help is greatly appreciated thank you.

user3117509
  • 833
  • 3
  • 14
  • 32

2 Answers2

2

Just found the answer here: https://stackoverflow.com/a/7574136/3117509

I tried searching earlier but was searching for "search array for string" when I should have been searching for something like "search for string within a string" or "search for text within a string."

Community
  • 1
  • 1
user3117509
  • 833
  • 3
  • 14
  • 32
-1

If I understand your question correctly, you're trying to iterate through an array and find if a string is there? Don't have access to a Mac right now, so I'm not sure if this will compile.

NSArray* someArray = [[NSArray alloc] initWithObjects:@"test", @"test1", @"test2", nil];

for(int i = 0; i < (int)[someArray count]; i++) {
    if([[someArray objectAtIndex:i] isEqualToString @"test"]) {
       //match found. handle the match
    }
}
rgajrawala
  • 2,148
  • 1
  • 22
  • 35
Carpetfizz
  • 8,707
  • 22
  • 85
  • 146