This guide will introduce you to automatic reference counting (ARC). ARC is fully supported by Kobold2D and enabled by default in all template projects. If you start a new Kobold2D project, you're already using ARC. Of course you can disable ARC but you shouldn't really need to.
This guide also explains what you need to be aware of when interfacing with C or C++ libraries (ie. Chipmunk, Box2D) in an ARC-enabled project.
| Kobold2D has automatic reference counting (ARC) enabled by default. |
What is ARC?
Automatic Reference Counting (ARC) for Objective-C makes memory management the job of the compiler. By enabling ARC with the new Apple LLVM compiler, you will never need to type retain or release again, dramatically simplifying the development process, while reducing crashes and memory leaks. The compiler has a complete understanding of your objects, and releases each object the instant it is no longer used, so apps run as fast as ever, with predictable, smooth performance.
Kobold2D ARC Documentation
- ARC Requirements for Development and Deployment — ARC has several requirements both for development and for deployment, ie on which devices and OS versions an ARC app runs on.
- What you need to know about ARC — This article tells you what you must know about ARC to be able to work with it, or convert an existing Objective-C project to ARC.
- ARC with C or C++ code (Chipmunk, Box2D) — All is fine and well with ARC in Objective-C land. However, as soon as you also work with C or C++ code — such as the Chipmunk or Box2D libraries, or the Core Foundation framework — you may find yourself facing compiler errors.
- Enabling ARC in legacy Kobold2D projects — If your project is based on Kobold2D Preview 5 or earlier, you will have to perform the following steps to enable ARC in your project.
- Disabling Automatic Reference Counting — If you want to deploy Kobold2D apps to devices running iOS 3 you must disable ARC.
More about ARC
If you want to understand in layman's terms how ARC works, you should read this question on stackoverflow.com: How does the new automatic reference counting mechanism work?
If you're totally into the nitty-gritty technical details of ARC you might want to read the LLVM compiler's Automatic Reference Counting documentation.
Mike Ash has summarized how ARC works with many practical examples.
On a higher level, Wikipedia tells us what reference counting actually is and how it works.



