Ad space (banner)
๐ŸŽObjective-C Lessons
Lesson 2 / 68

Your first output (NSLog)

This lesson covers the basics of printing in Objective-C with NSLog, with the aim of getting a feel for what kind of language Objective-C is.

NSLog displays text on the screen. Objective-C was the main language of Apple development before Swift, and is still used to maintain long-standing iOS and Mac codebases.

The sample code loads the Foundation framework with #import <Foundation/Foundation.h> and runs NSLog(@"Hello, Objective-C!") inside an @autoreleasepool memory-management block. Putting @ in front of a string is characteristic of Objective-C.

A common early stumble is how much the @ symbol appears. Objective-C extends C, so its own features (string literals, objects) need an @ in front — which is confusing at first.

In professional work, Objective-C still turns up when maintaining older iOS apps and wherever existing C code needs to be used.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Objective-C directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)