I was reading the Apple document “Cocoa Fundamentals Guide” and ran across some nice class hierarchy charts for Foundation classes that I thought I’d share. They are located in the section of the document called “What Is Cocoa?“.
These diagrams logically group the classes of the Foundation framework in categories. Classes in blue-shaded areas are present in both the OS X and iOS versions of Foundation; classes in gray-shaded areas are present only in the OS X version.
In creating my first iPhone app which uses the Address Book, I discovered the world of memory management with iOS. I wanted to share a few things I’ve learned and provide lots of links for your reference.
ARC, retain counts and CFRelease
Admittedly, if you stick strictly to Foundation code, you probably don’t need to be concerned too much about what happens under the hood. With the introduction of ARC (Automatic Reference Counting), iOS takes care of much of this for you. It’s when you also need to deal with Core Foundation (CF), which the Address Book uses, that things become tricky. CF has a concept of object ownership and memory management using retain counts. An object can have multiple owners (retain count > 1), but when you are done with that object the retain count had better be zero or you’ll create memory leaks. To accomplish this, you need to use CFRelease().
Posted in iOS
Tagged address book, apple, arc, core foundation, foundation, iOS, leak, memory, objective c, retain count, zombie