Skip to content

Objective-C basic syntax

Objective-C basic syntax

- (void) func { ... }
- (void) func:(arg1Type)arg1 { ... }
- (void) func:(arg1Type)arg1 optionalArgName:(arg2Type)arg2 { ... }
- (void) func:(arg1Type)arg1 :(arg2Type)arg2 { ... }
[object method];
[object method:arg1 optionalArg2Name:arg2]
[object method:arg1 :arg2]
ClassName *instanceName = [[ClassName alloc] init];

–> Source ↗