I'm still learning by doing, so please, if this sounds like a noob question, that's probably what it is.
I'm trying to iterate through a NSDictionary (messeges) and grab the value on a certain key.
When I run this code I get the following error"* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 4 beyond bounds [0 .. 3]'"
NSArray* keys = [messages allKeys];
int count = [keys count] ;
for (int i=0; i < count; i++) {
for(NSString* key in keys) {
if ([key isEqualToString:@"messagesinconversation"]) {
NSArray* arr = [messages objectForKey:key];
NSString *sentby = [[arr valueForKey:@"sentby"] objectAtIndex:i];
NSLog (@"%@", sentby);
}
}
}
Could somebody point me in the right direction?
[[arr valueForKey:@"sentby"] objectAtIndex:i];asihas no relation to thearrarray, it's an index into thekeysarray.