oriented capabilities and a dynamic runtime” • Inherits C syntax, primitives, flow control • Adds syntax for classes, methods, object literals • Dynamically typed, defers a lot to runtime
framework #import <Foundation/Foundation.h> ! // Prefixed class name (no namespaces ) : superclass @interface BRYCalculator : NSObject ! // Instance method with two arguments - (NSInteger)add:(NSInteger)number1 toNumber:(NSInteger)number2; ! // Class method ("static" to you Java folk) + (void)initialize; ! @end
“frame” (coordinates and size), determines where it shows up on screen • Frame can be set manually or via constraints (AutoLayout) • Has an array of “subviews” (forming a hierarchy) • Can be configured in code or in Interface Builder UIView
• Provides hooks like “viewWillAppear”, “viewWillDisappear”, rotation • View controllers can have children • Can implement “container view controllers” (e.g. tab bar, navigation bar) UIViewController
offset changes [scrollView addObserver:self forKeyPath:@“contentOffset”]; ! // `[self wipeDatabase:]` will be called when notification is posted [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wipeDatabase:) name:@"UserDidLogoutNotification"]; Observing changes
[queue addOperationWithBlock:^{ // Do something on a background thread [[NSOperationQueue mainQueue] addOperationWithBlock:^{ // Update the UI on the main thread }]; }]; Concurrency