Objective-C, Window-based Applications, MVC

2 downloads 169 Views 344KB Size Report
OSes Used Regularly. 0. 30. 60. 90. 120. 150. BSD. Linux. Mac OS. Solaris. Windows XP. Windows Vista. Windows 7. Page 5.
iOS Objective-C, Window-based Applications, MVC

OSes Used Regularly 150 120 90 60 30 0 D BS

x u n Li

S O c Ma

is r a ol

ow d in

S

W

P X s W

s w o d n i

ta s i V W

7 s ow d in

Devices Used Regularly 100 75 50 25 0

A

id o r nd

ne o ph A

d i o r nd

t

e l b ta

ck a l B

y r r Be

d a P i

ne o iPh

d o P i

ch u to

bO e w

ne o h p S W

7 s ow d in

ne o ph

Most Excited For... Web 12% Android 39% iOS 48%

.h @interface  Foo:  NSObject  {        //  instance  variables } //  declarations  of  methods @end

.m @implementation  Foo //  definitions  of  methods @end

Instance Variables @protected @private @public

Class Methods

+alloc;

Instance Methods -­‐  (int)age; -­‐  (void)setAge:(int)age;

-­‐  (void)init; -­‐  (void)initWithName:(NSString  *)name  andAge:(int)age;

Messages [student  age]; [student  setAge:20];

[student  init]; [student  initWithName:@"Alice"  andAge:20];

Selectors alloc age setAge: init initWithName:andAge:

@property assign copy retain atomic nonatomic readonly readwrite

@synthesize

Memory Management alloc    autorelease    dealloc    release    retain

Collections NSArray NSMutableArray NSDictionary NSMutableDictionary NSSet NSMutableSet ...

Fast Enumeration for  (id  foo  in  bar)  {        //  do  something  with  foo }

Categories @interface  Foo  (Bar) -­‐(void)baz; @end

Protocols @interface  Student    { } ... @end

Protocols @implementation  Student ... -­‐(id)copyWithZone:(NSZone  *)zone {        Student  *s  =  [Student  allocWithZone:zone];        [s  initWithName:_name  andAge:_age];        return  s;   } ... @end

NSException @try  {        //  try  something  here } @catch  (NSException  *e)  {      //  handle  exception  here } @finally  {        //  do  something  here }

NSError NSError  *e  =  nil; if  ([foo  bar:baz  error:&e]  ==  nil) {        //  handle  error }

MVC

http://developer.apple.com/library/ios/documentation/iphone/conceptual/iPhone101/Articles/02_DesignPatterns.html