I am trying something very trivial here, but the program is terminating with a “EXC_BAD_ACCESS” in the NSLog. I am attempting to populate a mutable array with several dictionaries like this:
NSMutableArray *_recipientsMutArray = [[NSMutableArray alloc] init];
NSDictionary *r1 = [[NSDictionary alloc] initWithObjectsAndKeys: @"firsValue", @"firstKey", @"secondValue", @"secondKey", nil];
[_recipientsMutArray addObject:r1];
[r1 release];
Why?
The code that you have provided is fine, and shouldn't cause EXC_BAD_ACCESS, however you mention a crash with NSLog. A common mistake to make with NSLog is to provide a C-style string for the format string, rather than an NSString. The following will cause errors:
int i = 4;
NSLog("%d", i); // oh no!
Instead, you need to ensure that NSLog's first argument is an NSString, like this:
int i = 4;
NSLog(@"%d", i); // yay!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With