6. Objective C 2.0
• Objective C 2.0 - since Oct 2007 with OS X 10.5
• modern Garbage Collector
• 64 bit
• properties syntax - @synthesize, ...
• Dot-Notation
• Fast Enumeration - „for-in“
10. Typs and more
• id - dynamic typing
• BOOL (YES, NO) - bool (true, false)
• NSString, NSNumber, NSDate
• NSArray, NSSet, NSDictionary
• „nil“ - is a null pointer to an Objective-C object.
• „Nil“ - is a null pointer to an Objective-C class.
• „NULL“ - is a null pointer to anything else.
13. Properties
// Copy the object during assignment.
@property (copy) MyModelObject *theObject;
// Declare only a getter method.
@property (readonly) NSView *rootView;
// Declare delegate as a weak reference
@property (weak) id delegate;
// Assign new value, change name of getter method
@property (assign, getter=isEnabled) BOOL enabled;
strong = Specifies that there is a strong (owning) relationship to the destination
object.
weak = Specifies that there is a weak (non-owning) relationship to the destination
object. If the destination object is deallocated, the property value is automatically
set to nil. (Weak properties are not supported on OS X v10.6 and iOS 4; use assign
instead.)
14. Dot-Notation vs. [...]
int x = foo.value;
int x = [foo value];
someView.frame.size.width = 30; // This is valid code!
myObject.property = YES;
[myObject setProperty:YES];
16. XCode Best Practice
• Code Completion (kein auto #import)
• Refactoring (auch für StoryBoard)
• StoryBoards (Komplex, XIB Files,
i18n)
• Build and Run (einfach und schnell)
• Developer Account (Hardware Tests
nur für 79 EUR pro Jahr)