The program shape in Objective-C
The classic frame: main, an autorelease pool, and NSLog out.
// The classic shape: an autorelease pool wrapping main, NSLog out.
#import <Foundation/Foundation.h>
int main(void) {
@autoreleasepool {
NSString *shop = @"Spindle Records";
NSLog(@"Opening %@", shop);
NSLog(@"Crates on the floor: %d", 12 + 3);
}
return 0;
}
How it works
#import <Foundation/Foundation.h>brings the object world in.@autoreleasepoolscopes the memory of everything inside.NSLog(@"Opening %@", shop)formats with %@ for objects.
Keywords and builtins used here
NSStringintmainreturnvoid
The run, in numbers
- Lines
- 11
- Characters to type
- 260
- Tokens
- 46
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 39 seconds.
Step 1 of 3 in Values, step 1 of 27 in Language basics.