Question

Have only one question "How to right dealloc object when app goes to background ?". I'm working on some app, everything works great and fine. When i put app to background and then start it again it's crashes. Not immediately(app stars right where i closed it) , but when i choose some of cells or just scroll tableview for example. So i'm pretty sure that app calls already released data.

here is example of dealloc

- (void)dealloc {


    [anObject release];
    [array release];
    [locationManager release];
    [currentLatitude release];
    [currentLongitude release];
    [filteredListContent release];
    [super dealloc];
}

Any advises?

Was it helpful?

Solution 2

I review and re-write my own code. The problem was as i expected in deallocation of memory. I used autorelease where i shouldn't. It still weird cause app did crash when i open it again.

Thanks everyone, not you guys who gift to me 2 negs, you are jerks. Don't be offended,but instead of give some advise you just give ungrounded negs.

OTHER TIPS

Unless you specifically deallocate things in your app delegate's applicationDidEnterBackground method, nothing should be deallocated for you automatically.

I have never experienced the problem you're having. Are you certain the same thing doesn't happen after a while even if you never put it in the background?

Here's a good explanation of how all of the backgrounding stuff fits together:

Understanding iOS 4 Backgrounding and Delegate Messaging

Never release any object like this. Use

- (void)dealloc {

if(anObject){
[anObject release];
anObject = nil;
}
if(array){
[array release];
array = nil;
}
//same approach for all.

 [super dealloc];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top