NSMutableArray EXC_BAD_ACCESS (code=1)
objective-c, xcode
Solution
Change your
NSArray *randomNounList = [NSArray arrayWithObjects:@"Bear", @"Spork", "Mac", nil];
to:
NSArray *randomNounList = [NSArray arrayWithObjects:@"Bear", @"Spork", @"Mac", nil];
You forgot `@` before `"Mac"`
Hope it helps
Problem
I have no idea why, but my NSMutableArray 'items' will not take more than 5 elements. Can someone please help? I'm following the Big Nerd Ranch iOS Programming book. This code works fine: ``` NSMutableArray *items = [[NSMutableArray alloc] init]; for (int i = 5; i < 10; i++) { BNRItem *p = [BNRItem randomItem]; [items addObject:p]; } ``` However if I change the initial value of i to 4 or less the program crashes when exiting the for loop: ``` NSMutableArray *items = [[NSMutableArray alloc] init]; for (int i = 4; i < 10; i++) { BNRItem *p = [BNRItem randomItem]; [items addObject:p]; } ``` Error screenshot: http://db.tt/3CdueSYh