Skip to content
Hello, Objective-C
step 1/5

Reading — step 1 of 5

Learn

~1 min readBasics

Objective-C was designed in 1984 by Brad Cox at StepStone — a thin Smalltalk-style messaging layer on top of C. NeXT picked it up; Apple inherited it; for 30 years it was THE language for Mac and iOS apps.

#import <stdio.h>

int main() {
    printf("Hello, Objective-C!\n");
    return 0;
}

That looks like C — and it is. Pure C compiles in Objective-C unchanged. The OC parts come in when you create classes and send messages.

Sending a message — Objective-C's signature syntax:

[receiver methodName];
[receiver methodWithArg: value];
[receiver methodWithFirst: a second: b];

The brackets are message sends. NSLog is the canonical printer for OC apps:

#import <Foundation/Foundation.h>
NSLog(@"Hello, %@", @"World");    // @"..." is an NSString literal

But NSLog writes to stderr with timestamps — for clean stdout in test cases, prefer printf.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…