Get In Touch
This form does not yet contain any fields.

    « Text Input in UIAlertViews | Main | iOS Twitter Search Tutorial »
    Tuesday
    Oct252011

    Simple ARC explanation

    Dont worry about it.  Memory management is one of the hardest concepts for new developers to wrap their heads around. With iOS 5 and ARC this issue is mitigated.

    Developers can alloc and init objects like they normally would, but now the compiler takes care of cleaning up memory when the object is no longer needed.  In other words, stop worrying about it, you no longer need to be obsessive about writting a release everytime you write alloc. In fact you can remove dealloc functions from your code altogether.  This even works for Blocks, stop worrying about including the autorelease.

    There is even an automated way to convert old code to ARC, within Xcode go to Edit --> Refactor --> Convert to Objective-C ARC. This will walk you through step by step how to convert your code and even do a precheck to make sure nothing will break.

    There are also compiler flags you can provide to opt-in or opt-out of ARC.  This is incredibly useful if you are using pre-ARC libraries, so you can have ARC on the rest of the project and use retain/release on the older code.

    Opt-in Flag = -fobjc-arc

    Opt-out Flag = -fno-objc-arc

     

    Apple's initial baselines also are showing that there is a healthy performance gain of 2.5x faster than a normal retain/release.  It is 6x faster than autorelease as well.

    Stop Worrying. Start Developing.

    Reader Comments (1)

    November 6, 2011 | Unregistered Commenterlederm

    PostPost a New Comment

    Enter your information below to add a new comment.

    My response is on my own website »
    Author Email (optional):
    Author URL (optional):
    Post:
     
    Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>