To answer the title of your question:
NSString *compareString = @"something";
NSMutableArray *indexesOfMatches = [[NSMutableArray alloc]init];
for (NSString *string in theArray) {
if ([string isEqualToString:compareString]) {
NSNumber *index = [[NSNumber numberWithInterger:[theArray indexOfObject:string]];
[indexOfMatches addObject:index];
}
}
//indexOfMatches will now contain NSNumber objects that represent the indexes of each of the matching string objects in the array
I think that using an NSDictionary would be better for you though. Then you can simply keep the first and last names as Key Value pairs.
NSDictionary *names = @{@"lord" : @"krishna", @"priya" : @"amirtha" };
Then you can just do value for key when you get the first name:
NSString *firstName = @"lord";
NSString *lastName = [names valueForKey:firstName];
forloop. It really works!! You should try it some time.