Alex
Alex

Reputation: 2513

EXC_BAD_ACCESS signal received

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

Upvotes: 0

Views: 357

Answers (3)

JeremyP
JeremyP

Reputation: 86661

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

Upvotes: 1

Thomas Clayson
Thomas Clayson

Reputation: 29935

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.

Upvotes: 0

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

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.

Upvotes: 0

Related Questions