Memory Management Question in Objective C

Memory Management Question in Objective C

I have a tableviewcontroller where I populate some data from a sqlite db and for each row, I download a file from a http server and cache it locally. I cache it only when the "detailsview" is opened. And the detailsview responds back to this table through a delegate after the file download is complete.

But, when this tableview itself is popped out of the navicontroller., the call to delegate fails with a EXEC_BAD_ACCESS

I called [_delegate retain] in the setDelegate of the details view and everything works fine, but I'm not sure whether this will leak memory...

Could anyone advise?

Is there a portable OpenGL UI Library (Buttons, Lists, Windows, Dropdown etc)?


Downloading images from a server iPhone SDK
Your delegate is receive ting released prematurely, and sending a message to an invalid object will call EXEC_BAD_ACCESS. iPhone touch cancelling in OS 3.0Retaining it will fix the problem, although in universalit's good practice to not have an object retain its delegate, as there is the potential for retain cycles, so you might need to rethink your structure. UIPasteboard - cannot copy textIf you're releasing your delegate when the view is dealloc'ed, you need to remove it unless you're also retaining the delegate in setDelegate:.. Websites for the iPhone - but what about other platforms?
Fitting a UIDatePicker into a UIActionSheetTransitions and setting up Layers/Scenes in cocos2d iPhone


Polyphonic sound playback
Generally, delegates are not retained to avoid retain cycles. If the delegate may be released before you, then it is the responsibility of the delegate to clear your reference before it is finished being deallocated (eg in its dealloc).. However, if any property is set to "retain" or "copy", then you would retain/copy it in the setter (or use @synthesized setters which will did it for you), and release it in dealloc to avoid leaking. As said above though, this may lead to a retain cycle so this neither object ever receive s deallocated.. I would suggest you turn on any memory debugging with environment variables NSZombieEnabled and NSAutoreleaseFreedObjectCheckEnabled and see if it tells you which object is being over released..

54 out of 100 based on 49 user ratings 524 reviews