WWDC 2013: Advances in Objective-C

Modules

@import optionally replaces the long, cumbersome process of:

#include

Link binary with libraries

and makes it a whole lot more scalable to build large applications. What it does is a semantic import rather than a textual inclusion.

To use go into Settings and enable BUT it requires iOS7 and the OS X 10.9 SDK.

Tagged Pointers

For small value objects, the object is stored in the pointer itself which makes it over 100x faster and 3x more space efficient. 

BUT, public data structures are increasingly becoming private. i.e. use the APIs to introspect.

i.e. use object_getClass and isKindOfClass

Garbage Collection

ARC is increasingly being used in new frameworks. So, use it!

e.g. Xcode 5.0 now uses ARC.

To convert code use the ARC Migrator which does the heavy lifting.

See WWDC 2012 for more details on ARC.

New Memory Management Warnings

Improving CoreFoundation and ARC

NSString *string = (__bridge NSString *)CFDictionaryGetValue(_dict, @”key”);

The ARC compiler must reason about object lifetime.

This requires retain count “bridging” in and out of ARC.

+1 via CFBridgingRetain()

-1 via CFBridgingRelease()

0 via “__bridge” casts to avoid mistakes

Common CF APIs now allow implicit bridging.

Related sessions:

WWDC 2013: What’s New in the LLVM Compiler

WWDC 2013: Optimize Your Code Using LLVM

 

Leave a Reply

Your email address will not be published. Required fields are marked *