Search code examples
objective-cioscrashdealloc

Request traitement crash - Message sent to deallocated instance


I'm executing an asynchronous method on an object and when my request is finish I print the result in a label. My problem is : if I launch my request and then I remove my object, I have a crash on my setText method (because my object is deallocated).

How can I avoid this crash even if my object has been released ?

Is there any test to do ?


Solution

  • 1) Don't remove your object until the request is finished :)

    2) Cancel the request (not always possible depending on your object)