In my application I have One MutableArray comes like this,
Idlist:(
1,
2,
3
)
I have one string IdData. in IdData value is 2.
Now i want to check Itemid contain in my MutableArray.
I have tried with this,
if ([Idlist containsObject:IdData])
{
NSLog(@"Item is in List");
}
else
{
NSLog(@"Item is not in List");
}
But every time I going to else loop.
How can i solve this problem?
Use code like this to identify NSString in your array:
NSMutableArray *arr = [[NSMutableArray alloc] init];
[arr addObject:@"Best"];
[arr addObject:@"Good"];
[arr addObject:[NSNumber numberWithInt:3]];
for(NSString *str in arr)
{
if(str && [str isKindOfClass:[NSString class]])
{
NSLog(@"String: %@\n",str);
}
}