Gianluca
Gianluca

Reputation: 2449

really dumb question with NSMutableArray and addObject

where I'm wrong??

oldEvents is NSArray...

NSMutableArray *oldIDs = [[NSMutableArray alloc] init];

for(int i=0; i<[oldEvents count]; i++){
    [oldIDs addObject:[(NSDictionary *)[oldEvents objectAtIndex:i] objectForKey:@"id"]];
}

NSLog(@"Count: %@", [oldIDs count]);

I can't figure out this problem!!! I receive EXC_BAD_ACCESS when I try to log oldIDs count

thank you!

Upvotes: 0

Views: 158

Answers (2)

Yagiz Ozturk
Yagiz Ozturk

Reputation: 5428

İn case of NSLog(@"Count: %@", [oldIDs count]);

you have to write

NSLog(@"Count: %d", [oldIDs count]);

and check that (NSDictionary *)[oldEvents objectAtIndex:i] has value for key id.

Upvotes: 2

Adrian Sarli
Adrian Sarli

Reputation: 2356

Are you sure you aren't releasing oldIds somewhere? The code looks all right to me.

Upvotes: 0

Related Questions