You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tripside edited this page Mar 5, 2012
·
3 revisions
RestKit uses delegates to signal that mapping operations are complete, an error occurred or some other event has happened. Delegates are normally not retained. You must be sure that when a delegate is called, its target is an allocated, valid object. If it is not, your app will crash.
Clients will frequently fetch some objects from the server in a UIViewController like so:
Behind the scenes, this creates an RKObjectLoader that will send you delegate messages. It might be tempting to get a reference to the RKObjectLoader and retain it, and then when your view controller's destructor is called nil out the loader's delegate. This is certainly possible using the block versions of loadObjectsAtResourcePath. However, a more common idiom is to just issue:
from the dealloc method of your UIViewController. This handles the situation nicely. Thanks to Jeff Arena for letting me know about this RestKit pattern.