Objective-C basic syntax - jaredgorski.org

Objective-C basic syntax

programming, ios, objective-c, syntax
  • Function signature
- (void) func { ... }
- (void) func:(arg1Type)arg1 { ... }
- (void) func:(arg1Type)arg1 optionalArgName:(arg2Type)arg2 { ... }
- (void) func:(arg1Type)arg1 :(arg2Type)arg2 { ... }
  • Method calling
[object method];
[object method:arg1 optionalArg2Name:arg2]
[object method:arg1 :arg2]
  • Object instantiation
ClassName *instanceName = [[ClassName alloc] init];

–> Source ↗