typestar

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

  1. #import <Foundation/Foundation.h> brings the object world in.
  2. @autoreleasepool scopes the memory of everything inside.
  3. NSLog(@"Opening %@", shop) formats with %@ for objects.

Keywords and builtins used here

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.

Type this snippet

Step 1 of 3 in Values, step 1 of 27 in Language basics.

Next →

The program shape in other languages