I’m using ARC in an iOS app i’m building.
I’ve created some objects, in which they connect to a web server asynchronously to download data.
I noticed that when I alloc the object, it sends the request fine, but when it is time to receive ARC has already dealloc‘d the object, so that app crashes. Putting the variable in my header file solves this problem. But my concern is that If I’ve got a lot of these types of objects, wont memory usage go up? (Particularly when I no longer need the object once they’re finished)
Is there a better way to handle this in ARC, perhaps something similar to the old [NSObject release];
Thanks
Use a
@property(retain)for your instance variable in your header file.Set this property to
nilonce you are done with it (once you have received the response — or error — for your request for example) so the memory will be released by ARC.