Creating NSArray - EXC_BAD_ACCESS?
ios, iphone, nsarray, out-of-memory
Solution
Use the new Objective-C syntax:
NSArray *purchasedTimeArray = @[ timeRemainingTitle, blank, @"imagename.png", blank, description, @4 ];
Two benefits:
- Much easier to write.
- No need for `nil` terminator and if one of the other values are `nil` in value, all the objects still end up in the array.
As noted in the comments, the `@4` syntax translates to `[NSNumber numberWithInt:4]`.
Problem
When I try to create the `NSArray purchasedTimeArray`, I get a crash `EXC_BAD_ACCESS` ``` NSString *blank = @""; NSArray *purchasedTimeArray = [[NSArray alloc] initWithObjects: timeRemainingTitle, blank, @"imagename.png", blank, description, 4, nil]; ``` And yes, `timeRemainingTitle` and `description` still exist in memory. They are both NSStrings.