What is ARC:
ARC or automatic reference counting is a new concept that is added in the latest xcode with this feature you need not worry about managing your objects the LLVM 3.0 compiler which is newly added by apple will take care of it.
This means now you don’t have to retain, release or autorelease an object with ARC all this is done for you by the LLVM 3.0 compiler this is something very cool and very neat that apple has done for its developer.
How can it make developer life easy?
Earlier in objective c we had to do manual memory management which had the below rules:
· If you need to keep an object around you need to retain it.
· If you are the owner of an object you will release the object when its not in use.
· If you want to stop using an object you need to release it, unless you have used autorelease.
Imagine earlier before ARC we had to manually implement the retain, release and auto-release code in our application which was a bit tuff at the start but once if your familiar its a piece of cake.
Manual memory management at the beginning is a tuff task and even if you master it your are not 100% sure that you have taken complete care of memory at times mistakes due happen and these mistakes could lead to huge consequences called as “crash” because it might happen that you are pointing to an object that you have released or it might happen that you run out of memory if you have not released your objects well.
It is important to realize that ARC is a feature of the Objective-C compiler and therefore all the ARC stuff happens when you build your app. ARC is not a runtime feature (except for one small part, the weak pointer system), nor is it a garbage collector.
All that ARC does is insert retains and releases into your code when it compiles it, in the same way like we do it during the manual memory management. Also not only this LLVM also guides you during the development process and helps you fix minor bugs when you make mistakes as it is continuously evaluating what you type and identifies the coding mistakes that you make and also fix it for you.
Read more on Automatic reference counting
Hope that you have got the initial concept of ARC in my next post i shall explain what is strong and weak pointers, until then happy iCoding and have a great day.