Is it possible to access elements of an NSArray
based on index and use them for comparison/operations?
Just like arrayName[ith element]
in C/C++
Is it possible to access elements of an NSArray
based on index and use them for comparison/operations?
Just like arrayName[ith element]
in C/C++
Yes , you can access elements of an NSArray based on index .
NSArray *a=@[@"s1",@"s2",@"s3"];
NSLog(@"%@",a[1]);
Try this
arrayName[yourIndex];
or
[arrayName objectAtIndex:yourIndex];
You can use 'Index Subscripting Literal' that Apple Provide on iOS 6 SDK later
NSArray *array = @[1, 2, 3];
NSLog(@"%@", array[0])