iphone – EXC_BAD_ACCESS signal received – Education Career Blog

I am getting a EXC_BAD_ACCESS signal when calling the following line:

self.distance = NSNumber numberWithDouble:currentLocation distanceFromLocation: self.location;

This is only happening in iOS 3.2 for iPad,

I know this is a memory issue but i can’t seem to see what is wrong with the above line?

edit: here is the full method:

-(void)updateDistance:(CLLocation *)currentLocation {

    self.distance = NSNumber numberWithDouble:currentLocation distanceFromLocation:self.location;

    placeWrapper.distance = self.distance;

}

which is called like so:

place updateDistance:self.currentLocation;

self.currentLocation is created here:

CLLocation *location = CLLocation alloc initWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude;

self.currentLocation = location;

location release;

Another edit 🙂

here is the stack trace: http://pastie.org/1222992

,

Run your code with NSZombieEnabled set. This should tell you if you are over releasing or under retaining somewhere.

,

It’s difficult to say without demonstrating where/how you’re creating “currentLocation”, “location”, or possibly even “self”. I’m guessing either currentLocation or self.location are not properly retained on creation/setting.

,

You need to retain something…

currentLocation retain

or

self.location retain;

but you have to do it further up the code. Something’s getting “forgotten” or goes “out of scope” so try those retains.

DON’T FORGET TO RELEASE WHATEVER IT IS THAT YOU’RE RETAINING.

Leave a Comment