EXC_BAD_ACCESS on NSError

The following code kept giving me EXC_BAD_ACCESS,


NSError* error;
 NSMutableArray* configurationArray = [[mManagedObjectContext executeFetchRequest:request error:&error] mutableCopy];
 if (error != nil) {
 NSLog(@"Error: %@", error);
 }

Apple has a list of suggestions on what might be causing this. However my problem was different, which was that I wasn’t initializing error pointer as such,


NSError* error = nil;

I miss Java :(

One thought on “EXC_BAD_ACCESS on NSError

  1. Duh! Oh wow, thank you. I had written “NSError *error;”, instead of “NSError *error = nil;”. Thanks for the reminder to initialize!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>