Search code examples
objective-cxcode4xcode4.2

Recent Changes in Objective-C runtime/ Xcode 4.2 code


I've just started learning Obj-C and i'm a little confused. The videos I've been watching on Lynda.com were created with Xcode 4, but there are so many differences that I find it hard to believe that all of them occurred in 2 point releases. For instance:

In the video you could write:

@property NSString * myString

And it would be fine, but now in 4.2 it throws an error unless you write something like:

@property (nonatomic, retain) NSString * myString

In addition, there are no longer init or dealloc methods in the implementation code by default and NSAutoReleasePool is implemented completely differently. What gives?


Solution

  • While I can't guarantee that this list is exhaustive, the differences you'll find on the net are:

    • Objective-C 1.0 or 2.0
    • Old or modern runtime
    • Manual or automatic reference counting

    My personal take on the main differences is:

    • Objective-C 2.0 brought properties and synthesized accessors among other things
    • The modern runtime has a different way of organizing instance variables (non-fragile instance variables), but you probably won't notice in day-to-day development work
    • The modern runtime also allows 64-bit apps if the OS supports it
    • Automatic reference counting lets you do away with retain/release code at the modest cost of following the coding and naming conventions

    There are more differences, but these are the most important ones as I see it - personally I rarely have to use autorelease pools, and if I understand correctly the new syntax does not change the functionality.