Objective-C Foundations
Objects and messages, properties, Foundation values, UTF-16, protocols, categories, blocks, ARC relationships, recoverable errors, a tiny local file and separate source files. Introductory macOS-only scope.
Audience: Learners familiar with the C Foundations pack and basic terminal use.
Practice: 4 to 6 hours.
Runtime and boundaries: In a new owned practice directory, compile an exported example with /usr/bin/clang -x objective-c -std=c17 -fobjc-arc -fno-modules -Wall -Wextra -Werror "Example.m" -framework Foundation -o "Practice", then run ./Practice. Replace Example.m with the exact filename. For Objective-C 09 Main.m, also pass "Atlas minutes.m" and save "Atlas minutes.h" beside both files. The file example creates and retains Atlas practice note.txt; a second run intentionally refuses it. Use only the installed Apple toolchain with macOS Foundation. Compilation uses SDK 27.0 headers; execution uses system Foundation 6.9 (5027.0.69) on macOS 27.0.1 arm64. No iOS, GNUstep, other OS, Objective-C++, UI, concurrency or package-manager support is tested. The offline browser exports text and never compiles or executes these programs.
Lessons
Build and run distinct stages
A .m source is compiled as Objective-C and linked with Foundation. This pack pins Apple Clang, ARC and a C17 base mode; C17 is not an Objective-C standard edition. Compiler acceptance does not prove correct behavior. Expected rejected fixtures are recorded separately and are never executed. The exported examples are trusted authored source, not a sandbox for arbitrary code.
Objects, messages and initialization
A class describes an interface and implementation. + marks class methods; - marks instance methods. Selector components and parameter order form the message name. Properties usually synthesize accessor methods and storage. An initializer calls its superclass and may return nil. Validate inputs before establishing invariants, and distinguish a nil Objective-C receiver from an invalid C pointer.
Strings, values and collections
Foundation provides NSString, NSNumber, NSArray and NSDictionary; these are framework types, not a second language. NSString length and NSRange offsets use UTF-16 units. Composed-sequence enumeration is different from counting bytes. Check NSNotFound and collection bounds. nil means absence; NSNull is an object representing explicit null. Sort dictionary keys when output order matters.
Copying and ownership
A strong relationship owns an object; weak observes without keeping it alive and becomes nil when the supported object is deallocated. A copy property invokes copying on assignment, which need not allocate a distinct object or deep-copy an object graph. ARC inserts ownership operations; cycles can still leak. Autorelease pools bound pending autoreleases and are not garbage collectors. nonatomic properties do not make concurrent mutation safe.
Protocols, categories and blocks
Protocols declare method contracts; adopting classes must supply required behavior. Class extensions can declare implementation details. Categories add methods but must avoid name collisions; this pack adds a prefixed method only to its own class. Blocks capture state. A block owned by an object can create a cycle if it strongly captures that object; the synchronous example uses a weak capture and a temporary strong local.
Errors and dynamic boundaries
Follow each API return-value contract before reading NSError. NSError outputs need not be cleared on success. Cocoa conventions treat exceptions as programming errors, not the ordinary invalid-input path. A JSON parser returns Foundation objects: validate their classes, required fields and application bounds separately. Lightweight generics and nullability annotations are compiler aids, not runtime schema validators.
Local files and source organization
Use a new owned practice directory. The file example retains a tiny UTF-8 file, refuses an existing path and requests a no-overwrite write. It is not a defense against an attacker controlling the directory. Export the local header and implementation beside the multi-file main, then compile both .m files. No module, package manager, GUI framework or network operation is needed.
What the evidence means
Normal compilation, execution output, boundary checks and expected compiler rejections are different evidence categories. These tests cover fixed inputs on one macOS arm64 compiler/SDK. They do not establish whole-language mastery, cross-platform compatibility, performance, arbitrary-code isolation or absence of every memory defect. Browser, PDF, accessibility and final Library release checks remain separate gates.
Reference cards
Source: .m / clang -x objective-c
Objective-C source mode; compile and link before running.
Ownership mode: -fobjc-arc
Enable automatic reference counting for Objective-C objects.
Classes: @interface / @implementation
Declare the interface and implement methods.
Messages: [receiver method:argument]
Send a selector with ordered arguments.
Methods: + / -
Class versus instance methods.
Initialization: instancetype / init / nil
Initialize via the superclass; handle a nullable result.
Properties: nonatomic, copy / strong / weak
Choose semantics; nonatomic provides no synchronization.
Literals: @"text" / @20 / @[] / @{}
Create object strings, boxed numbers and collections.
Absence: nil / [NSNull null]
No object versus an explicit null object.
Text units: length / NSRange / NSNotFound
UTF-16 offsets and a checked failed-search marker.
Protocols: @protocol / id<Protocol>
A declared method contract; implement required behavior.
Categories: @interface Class (Category)
Add distinctly named methods; do not replace existing behavior.
Blocks: ^{ ... } / __block
Capture behavior and explicitly mutable captured bindings.
Pools: @autoreleasepool
Bound pending autoreleases in this command-line program.
Errors: NSError ** / nullable result
Inspect the result before consulting the error output.
Boundary checks: isKindOfClass: / length limits
Validate dynamic values and application constraints explicitly.
Supporting configuration: Objective-C run instructions.txt
In a new owned practice directory, compile an exported example with /usr/bin/clang -x objective-c -std=c17 -fobjc-arc -fno-modules -Wall -Wextra -Werror "Example.m" -framework Foundation -o "Practice", then run ./Practice. Replace Example.m with the exact filename. For Objective-C 09 Main.m, also pass "Atlas minutes.m" and save "Atlas minutes.h" beside both files. The file example creates and retains Atlas practice note.txt; a second run intentionally refuses it. Use only the installed Apple toolchain with macOS Foundation. Compilation uses SDK 27.0 headers; execution uses system Foundation 6.9 (5027.0.69) on macOS 27.0.1 arm64. No iOS, GNUstep, other OS, Objective-C++, UI, concurrency or package-manager support is tested. The offline browser exports text and never compiles or executes these programs.
Expected compiler and warning-policy rejections
Four authored fixtures were rejected under the recorded Apple Clang and ARC configuration. Two are warnings promoted to errors by -Werror; independent syntax-only controls accepted those two without -Werror. No rejection fixture was executed. These results are separate from the twelve accepted runtime programs. Diagnostic wording is implementation-specific.
Examples and practice
Code below is reading material, not an execution console. Download the edition for the complete example files and companion modules.
Objective-C 01 - Objects and messages
The + method receives a class message; the - method receives an instance message. messageFor: requires a non-nil string. Messaging nil for this integer-valued length returns zero; passing a null C pointer to puts would not be safe. The print calls use only known non-nil UTF-8 strings.
#import <Foundation/Foundation.h>
#include <stdio.h>
@interface AtlasGreeting : NSObject
+ (NSString *)topic;
- (NSString *)messageFor:(NSString *)name;
@end
@implementation AtlasGreeting
+ (NSString *)topic { return @"Objective-C"; }
- (NSString *)messageFor:(NSString *)name {
return [@"Hello, " stringByAppendingString:name];
}
@end
int main(void) {
@autoreleasepool {
AtlasGreeting *greeting = [AtlasGreeting new];
puts([[AtlasGreeting topic] UTF8String]);
puts([[greeting messageFor:@"Ada"] UTF8String]);
NSString *absent = nil;
printf("Nil length: %lu\n", (unsigned long)[absent length]);
}
return 0;
}
Expected:
Objective-C Hello, Ada Nil length: 0
Example filename: Objective-C 01 Messages.m
Expected compiler or warning-policy rejection: unknown method rejected by this compiler and ARC configuration. Diagnostic containing no visible @interface. Expected rejection under this pack's compiler configuration; fixture not executed.
#import <Foundation/Foundation.h>
int main(void) { @autoreleasepool { (void)[@"x" atlasMissingMethod]; } }
Objective-C 02 - Properties and copying
The synthesized copy setter stores a string copy; strong stores an owning reference to the same mutable object. copy does not promise a new address or a deep copy of arbitrary graphs. nonatomic does not provide synchronization. This single-threaded fixture initializes both properties before use.
#import <Foundation/Foundation.h>
#include <stdio.h>
@interface AtlasNote : NSObject
@property (nonatomic, copy) NSString *title;
@property (nonatomic, strong) NSMutableString *shared;
@end
@implementation AtlasNote
@end
int main(void) {
@autoreleasepool {
NSMutableString *draft = [NSMutableString stringWithString:@"Read"];
AtlasNote *note = [AtlasNote new];
note.title = draft;
note.shared = draft;
[draft appendString:@" more"];
puts([note.title UTF8String]);
puts([note.shared UTF8String]);
printf("Same reference: %s\n", note.shared == draft ? "yes" : "no");
}
return 0;
}
Expected:
Read Read more Same reference: yes
Example filename: Objective-C 02 Properties.m
Objective-C 03 - UTF-16 and composed sequences
NSString length and NSRange offsets count UTF-16 code units, not bytes or displayed characters. Composed-sequence enumeration groups this authored combining accent with its letter. Segmentation can depend on the OS Unicode implementation; this fixture does not establish every script or emoji rule. Check NSNotFound before using a search range.
#import <Foundation/Foundation.h>
#include <stdio.h>
int main(void) {
@autoreleasepool {
NSString *text = @"Cafe\u0301";
__block NSUInteger sequences = 0;
[text enumerateSubstringsInRange:NSMakeRange(0, text.length)
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:^(NSString *substring, NSRange range, NSRange enclosing, BOOL *stop) {
(void)substring; (void)range; (void)enclosing; (void)stop;
sequences += 1;
}];
printf("UTF-16 units: %lu\n", (unsigned long)text.length);
printf("UTF-8 bytes: %lu\n", (unsigned long)[text lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
printf("Composed sequences: %lu\n", (unsigned long)sequences);
NSRange missing = [text rangeOfString:@"z"];
puts(missing.location == NSNotFound ? "Search: absent" : "Search: found");
}
return 0;
}
Expected:
UTF-16 units: 5 UTF-8 bytes: 6 Composed sequences: 4 Search: absent
Example filename: Objective-C 03 Text.m
Objective-C 04 - Collections and absence
Collections hold objects: NSNumber boxes these small integers and NSNull represents explicit null. nil is absence, not a collection element. Dictionary iteration has no report-order guarantee, so sort the ASCII keys. Lightweight generics aid compile-time checks; validate types at dynamic boundaries. The sum is safe only for these bounded authored values.
#import <Foundation/Foundation.h>
#include <stdio.h>
int main(void) {
@autoreleasepool {
NSArray<NSNumber *> *minutes = @[@10, @20, @30];
NSInteger total = 0;
for (NSNumber *value in minutes) { total += value.integerValue; }
printf("Total: %ld\n", (long)total);
NSDictionary<NSString *, NSNumber *> *totals = @{@"read": @20, @"code": @40};
for (NSString *key in [[totals allKeys] sortedArrayUsingSelector:@selector(compare:)]) {
printf("%s: %ld\n", [key UTF8String], (long)[totals[key] integerValue]);
}
NSDictionary<NSString *, id> *row = @{@"note": [NSNull null]};
printf("Explicit null: %s\n", row[@"note"] == [NSNull null] ? "yes" : "no");
printf("Missing: %s\n", row[@"missing"] == nil ? "yes" : "no");
NSArray *empty = @[];
puts(empty.firstObject == nil ? "First: absent" : "First: present");
}
return 0;
}
Expected:
Total: 60 code: 40 read: 20 Explicit null: yes Missing: yes First: absent
Example filename: Objective-C 04 Collections.m
Objective-C 05 - A protocol and a category
The protocol specifies a method contract; the class supplies the implementation. A class extension declares an implementation detail, not a security boundary. The category adds a prefixed method on this authored class. It adds no stored property and replaces no existing method. This initializer assumes its authored minutes input is valid; exercise A adds validation.
#import <Foundation/Foundation.h>
#include <stdio.h>
@protocol AtlasDescribing <NSObject>
- (NSString *)summary;
@end
@interface AtlasSession : NSObject <AtlasDescribing>
- (instancetype)initWithMinutes:(NSInteger)minutes;
@end
@interface AtlasSession ()
@property (nonatomic) NSInteger minutes;
@end
@implementation AtlasSession
- (instancetype)initWithMinutes:(NSInteger)minutes {
self = [super init];
if (self) { _minutes = minutes; }
return self;
}
- (NSString *)summary {
return [NSString stringWithFormat:@"%ld minutes", (long)self.minutes];
}
@end
@interface AtlasSession (AtlasLabel)
- (NSString *)atlas_label;
@end
@implementation AtlasSession (AtlasLabel)
- (NSString *)atlas_label { return [@"Session: " stringByAppendingString:[self summary]]; }
@end
int main(void) {
@autoreleasepool {
AtlasSession *session = [[AtlasSession alloc] initWithMinutes:25];
id<AtlasDescribing> view = session;
puts([[view summary] UTF8String]);
puts([[session atlas_label] UTF8String]);
}
return 0;
}
Expected:
25 minutes Session: 25 minutes
Example filename: Objective-C 05 Protocols.m
Expected compiler or warning-policy rejection: missing required protocol implementation: warning promoted by -Werror. Diagnostic containing -Wprotocol. Expected rejection under this pack's compiler configuration; fixture not executed.
#import <Foundation/Foundation.h> @protocol Required <NSObject> - (NSString *)summary; @end @interface Missing : NSObject <Required> @end @implementation Missing @end
Objective-C 06 - Weak ownership and a block
The counter owns its copied block, but that block captures only a weak reference back. A temporary strong local keeps the object alive during the synchronous call if it still exists. After the last owner and the inner pool are gone, the observer is nil. No intentional leaking cycle, asynchronous timing or manual release is demonstrated. ARC manages ownership; it is not a general leak or thread-safety guarantee.
#import <Foundation/Foundation.h>
#include <stdio.h>
@interface AtlasCounter : NSObject
@property (nonatomic) NSInteger value;
@property (nonatomic, copy) void (^tick)(void);
@end
@implementation AtlasCounter
@end
int main(void) {
@autoreleasepool {
__weak AtlasCounter *observer = nil;
@autoreleasepool {
AtlasCounter *counter = [AtlasCounter new];
observer = counter;
__weak AtlasCounter *weakCounter = counter;
counter.tick = ^{
AtlasCounter *current = weakCounter;
if (current != nil) { current.value += 1; }
};
counter.tick();
counter.tick();
printf("Value: %ld\n", (long)counter.value);
counter = nil;
}
printf("Owner released: %s\n", observer == nil ? "yes" : "no");
}
return 0;
}
Expected:
Value: 2 Owner released: yes
Example filename: Objective-C 06 Ownership.m
Expected compiler or warning-policy rejection: explicit release forbidden with ARC enabled. Diagnostic containing forbids explicit message send. Expected rejection under this pack's compiler configuration; fixture not executed.
#import <Foundation/Foundation.h>
int main(void) { @autoreleasepool { NSObject *value = [NSObject new]; [value release]; } }
Objective-C 07 - Parsing is not validation
A successful parse produces Foundation values, not a validated record. This wrapper accepts at most 1024 bytes, a dictionary root and a title of 1 to 40 UTF-16 units. It allows extra keys and does not enforce a general JSON schema or detect duplicate keys. Check the returned title first; the NSError output is only meaningful on failure and is not cleared on success. Nullability annotations document intent but do not perform runtime checks.
#import <Foundation/Foundation.h>
#include <stdio.h>
NS_ASSUME_NONNULL_BEGIN
static NSString * _Nullable AtlasTitleFromData(NSData * _Nullable data,
NSError * _Nullable __autoreleasing * _Nullable error) {
if (data == nil || data.length > 1024) {
if (error != NULL) { *error = [NSError errorWithDomain:@"AtlasInput" code:1 userInfo:nil]; }
return nil;
}
NSError *parseError = nil;
id root = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
if (root == nil) {
if (error != NULL) { *error = parseError; }
return nil;
}
if (![root isKindOfClass:[NSDictionary class]]) {
if (error != NULL) { *error = [NSError errorWithDomain:@"AtlasInput" code:2 userInfo:nil]; }
return nil;
}
id title = [(NSDictionary *)root objectForKey:@"title"];
if (![title isKindOfClass:[NSString class]] || [title length] == 0 || [title length] > 40) {
if (error != NULL) { *error = [NSError errorWithDomain:@"AtlasInput" code:3 userInfo:nil]; }
return nil;
}
return title;
}
NS_ASSUME_NONNULL_END
int main(void) {
@autoreleasepool {
for (NSString *text in @[@"{\"title\":\"Read\"}", @"{", @"[]"]) {
NSError *error = nil;
NSString *title = AtlasTitleFromData([text dataUsingEncoding:NSUTF8StringEncoding], &error);
if (title != nil) { printf("Title: %s\n", [title UTF8String]); }
else if (error != nil) { puts("Rejected with NSError"); }
else { return 2; }
}
}
return 0;
}
Expected:
Title: Read Rejected with NSError Rejected with NSError
Example filename: Objective-C 07 Errors.m
Objective-C 08 - A local UTF-8 round trip
Run only in a new owned practice directory. The fixed filename is retained, never removed by the program; a second run intentionally refuses it. The no-overwrite write option protects against an intervening existing file, but this is not a hostile-filesystem sandbox. The example performs explicit UTF-8 decoding and checks each API failure return. Disk-full and permission failures are handled but are not injected by the harness.
#import <Foundation/Foundation.h>
#include <stdio.h>
int main(void) {
@autoreleasepool {
NSString *path = @"Atlas practice note.txt";
NSFileManager *files = [NSFileManager defaultManager];
if ([files fileExistsAtPath:path]) {
fputs("Refusing an existing practice file\n", stderr);
return 3;
}
NSError *error = nil;
NSData *bytes = [@"Read for 20 minutes\n" dataUsingEncoding:NSUTF8StringEncoding];
if (![bytes writeToFile:path options:NSDataWritingWithoutOverwriting error:&error]) {
fputs("Write failed\n", stderr);
return 4;
}
NSString *text = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
if (text == nil) { fputs("Read failed\n", stderr); return 5; }
puts([text isEqualToString:@"Read for 20 minutes\n"] ? "Round trip: equal" : "Round trip: different");
}
return 0;
}
Expected:
Round trip: equal
Example filename: Objective-C 08 Files.m
Objective-C 09 - A local header and implementation
Export all three files and compile both .m files together. The header declares a nullable result; the implementation accepts only 0 through 120. This is a C-linkage function using Objective-C objects in one linked executable, not a module, framework or package.
#import "Atlas minutes.h"
#include <stdio.h>
int main(void) {
@autoreleasepool {
NSNumber *result = AtlasDoubleMinutes(20);
if (result == nil) { return 2; }
printf("Companion: %ld\n", (long)result.integerValue);
}
return 0;
}
Expected:
Companion: 40
Example filename: Objective-C 09 Main.m
Companion file: Atlas minutes.h
#ifndef ATLAS_MINUTES_H #define ATLAS_MINUTES_H #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN NSNumber * _Nullable AtlasDoubleMinutes(NSInteger value); NS_ASSUME_NONNULL_END #endif
Companion file: Atlas minutes.m
#import "Atlas minutes.h"
NSNumber *AtlasDoubleMinutes(NSInteger value) {
if (value < 0 || value > 120) { return nil; }
return @(value * 2);
}
Objective-C exercise A - A validated initializer
The initializer rejects nil, an empty or overlong title, and minutes outside 0 through 120. The title limit uses UTF-16 units and the setter-free public API preserves this toy record after initialization. init/new are unavailable at compile time; this is an API contract, not protection against runtime reflection or hostile subclassing.
#import <Foundation/Foundation.h>
#include <stdio.h>
NS_ASSUME_NONNULL_BEGIN
@interface AtlasRecord : NSObject
@property (nonatomic, copy, readonly) NSString *title;
@property (nonatomic, readonly) NSInteger minutes;
- (nullable instancetype)initWithTitle:(nullable NSString *)title minutes:(NSInteger)minutes;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
@end
@implementation AtlasRecord
- (nullable instancetype)initWithTitle:(nullable NSString *)title minutes:(NSInteger)minutes {
if (title == nil || title.length == 0 || title.length > 40 || minutes < 0 || minutes > 120) {
return nil;
}
self = [super init];
if (self) { _title = [title copy]; _minutes = minutes; }
return self;
}
@end
NS_ASSUME_NONNULL_END
int main(void) {
@autoreleasepool {
NSMutableString *title = [NSMutableString stringWithString:@"Read"];
AtlasRecord *record = [[AtlasRecord alloc] initWithTitle:title minutes:20];
if (record == nil) { return 2; }
[title appendString:@" more"];
printf("%s: %ld\n", [record.title UTF8String], (long)record.minutes);
AtlasRecord *invalid = [[AtlasRecord alloc] initWithTitle:@"" minutes:20];
puts(invalid == nil ? "Empty title: rejected" : "Unexpected acceptance");
}
return 0;
}
Expected:
Read: 20 Empty title: rejected
Example filename: Objective-C exercise A Record.m
Practice: Build a record with a copied nonempty title of at most 40 UTF-16 units and minutes in 0 through 120. Reject invalid initialization with nil and prevent ordinary init/new calls.
Objective-C exercise B - A stable report
This function accepts trusted dictionaries of short ASCII string keys and small integer NSNumber values. It does not validate a dynamic JSON boundary or arbitrary numeric ranges. Sorting keys produces stable output; an empty dictionary produces an empty string.
#import <Foundation/Foundation.h>
#include <stdio.h>
static NSString *AtlasReport(NSDictionary<NSString *, NSNumber *> *totals) {
NSMutableArray<NSString *> *lines = [NSMutableArray array];
for (NSString *key in [[totals allKeys] sortedArrayUsingSelector:@selector(compare:)]) {
[lines addObject:[NSString stringWithFormat:@"%@: %ld", key, (long)[totals[key] integerValue]]];
}
return [lines componentsJoinedByString:@"\n"];
}
int main(void) {
@autoreleasepool {
NSDictionary<NSString *, NSNumber *> *totals = @{@"read": @20, @"code": @40};
puts([AtlasReport(totals) UTF8String]);
printf("Empty report length: %lu\n", (unsigned long)AtlasReport(@{}).length);
}
return 0;
}
Expected:
code: 40 read: 20 Empty report length: 0
Example filename: Objective-C exercise B Report.m
Practice: Format the trusted coding/reading totals in sorted key order, one line per key. Return an empty string for an empty dictionary.
Objective-C exercise C - An explicit error contract
The parser accepts one to three ASCII digits with value 0 through 120, including leading zeros. The length bound keeps intermediate arithmetic small. A successful return does not promise to clear an existing NSError output. Eight comparisons execute in main; their unexpected-mismatch branch is not deliberately executed.
#import <Foundation/Foundation.h>
#include <stdio.h>
NS_ASSUME_NONNULL_BEGIN
static NSNumber * _Nullable AtlasParseMinutes(NSString * _Nullable text,
NSError * _Nullable __autoreleasing * _Nullable error) {
if (text != nil && text.length >= 1 && text.length <= 3) {
NSInteger value = 0;
BOOL valid = YES;
for (NSUInteger i = 0; i < text.length; i += 1) {
unichar unit = [text characterAtIndex:i];
if (unit < '0' || unit > '9') { valid = NO; break; }
value = value * 10 + (unit - '0');
}
if (valid && value <= 120) { return @(value); }
}
if (error != NULL) { *error = [NSError errorWithDomain:@"AtlasMinutes" code:1 userInfo:nil]; }
return nil;
}
NS_ASSUME_NONNULL_END
int main(void) {
@autoreleasepool {
NSArray<NSString *> *inputs = @[@"0", @"20", @"120", @"121", @"+2", @"", @" 2", @"002"];
NSArray *expected = @[@0, @20, @120, [NSNull null], [NSNull null], [NSNull null], [NSNull null], @2];
NSUInteger passed = 0;
for (NSUInteger i = 0; i < inputs.count; i += 1) {
NSError *error = nil;
NSNumber *actual = AtlasParseMinutes(inputs[i], &error);
BOOL accepted = expected[i] != [NSNull null];
BOOL correct = accepted ? [actual isEqual:expected[i]] : (actual == nil && error != nil);
if (!correct) { fputs("Unexpected test result\n", stderr); return 2; }
passed += 1;
}
printf("Cases: %lu passed\n", (unsigned long)passed);
}
return 0;
}
Expected:
Cases: 8 passed
Example filename: Objective-C exercise C Contract.m
Expected compiler or warning-policy rejection: lightweight generic mismatch: warning promoted by -Werror. Diagnostic containing -Wobjc-literal-conversion. Expected rejection under this pack's compiler configuration; fixture not executed.
#import <Foundation/Foundation.h>
int main(void) { @autoreleasepool { NSArray<NSString *> *names = @[@1]; (void)names; } }
Practice: Implement a small ASCII-only minutes parser with a nullable NSNumber result and optional NSError output. Accept leading zeros but reject signs, whitespace, non-ASCII digits, empty input and values above 120.
Prompt templates
These are editable planning prompts in the downloadable workbench; they do not contact an AI service here.
Build an ARC example
For {language}, help with {goal}. Runtime: {runtime}. Constraints: {constraints}. Provide original complete .m sources, companion files, exact compiler/linker commands and expected output. Identify Foundation dependencies separately from the language.Debug the correct stage
For {language}, help with {goal}. Runtime: {runtime}. Constraints: {constraints}. Separate compiler diagnostics, linker failures, runtime errors and wrong output. Check nil, method contracts and ownership without adding network or GUI dependencies.Test boundaries
For {language}, help with {goal}. Runtime: {runtime}. Constraints: {constraints}. Cover nil/NSNull, wrong dynamic types, Unicode units, bounds and NSError return contracts. Keep deliberate compiler rejections separate from accepted executable programs. Report only checks actually run.Refactor ownership safely
For {language}, help with {goal}. Runtime: {runtime}. Constraints: {constraints}. Preserve observable output and API contracts. Explain copy versus shared references, weak captures and retained cycles. Do not introduce manual retain/release under ARC.Document platform limits
For {language}, help with {goal}. Runtime: {runtime}. Constraints: {constraints}. State the Apple compiler, SDK, ARC mode, macOS architecture, input bounds, side effects and error-output policy. Do not claim iOS or cross-platform testing.Explain and practice
For {language}, help with {goal}. Runtime: {runtime}. Constraints: {constraints}. Use a concise original example and an exercise with a separate solution. Explain Objective-C versus Foundation, and static annotations versus runtime validation. Do not claim full-language mastery.Further reading
- Apple: About Objective-C — Language and framework distinction. Archived guide; historical UI and network recipes excluded.
- Apple: Defining Classes — Interfaces, implementations and method declarations. Archived guide; historical UI and network recipes excluded.
- Apple: Working with Objects — Messages, initialization and nil. Archived guide; historical UI and network recipes excluded.
- Apple: Encapsulating Data — Property copying, ARC relationships and weak references. Archived guide; historical UI and network recipes excluded.
- Apple: Values and Collections — Boxing, object collections and absence. Archived guide; historical UI and network recipes excluded.
- Apple: Working with Protocols — Declared protocol contracts. Archived guide; historical UI and network recipes excluded.
- Apple: Customizing Existing Classes — Class extensions and category method naming. Archived guide; historical UI and network recipes excluded.
- Apple: Working with Blocks — Captures, __block and ownership cycles. Archived guide; historical UI and network recipes excluded.
- Apple: Dealing with Errors — Return values and NSError conventions. Archived guide; historical UI and network recipes excluded.
- Clang: Objective-C ARC — ARC flags and ownership semantics; Apple compiler subset is tested locally.
- Clang: Objective-C Literals — Boxing and collection literal semantics; Apple compiler subset is tested locally.
- Apple: Characters and Grapheme Clusters — Archived NSString guide: UTF-16 units, composed sequences and range boundaries.
Download the offline edition
Complete Atlas 0.11.0 ZIP (6,079,970 bytes) · 411-page guide and catalogue PDF · Versioned source JSON
Unzip the edition and open Programming and Scripting Atlas.html, Web Foundations.html, Python Foundations.html, SQL Foundations.html, Shell Foundations.html, TypeScript Foundations.html Data Formats Foundations.html, C Foundations.html C++ Foundations.html, Ruby Foundations.html, Perl Foundations.html, Swift Foundations.html, Makefile Foundations.html, awk Foundations.html, sed Foundations.html, jq Foundations.html, XSLT 1.0 Foundations.html, Tcl Foundations.html, Expect Foundations.html or Objective-C Foundations.html locally. The original interactive workbenches retain their offline prompt-building, local presets and export controls. Read the included README before running examples yourself. The workbench does not execute pasted code or call an AI service; prompt text is for you to inspect and use separately.
Version 0.11.0 is pinned here. The other 257 registry entries remain planned; this edition does not claim complete language coverage.
Evidence and limits
Objective-C adds 12 accepted native programs, four separate compiler or warning-policy rejections, 120 root checks and 147 independent native checks. Two rejection fixtures are warnings promoted by -Werror; they are not intrinsic syntax failures. No rejected fixture was executed. Tests dated 26 October 2026 used Apple Clang 21.0.0, ARC, C17 base mode, macOS SDK 27.0 headers and system Foundation 6.9 (5027.0.69) on macOS 27.0.1 arm64. This is introductory macOS/Foundation coverage, not iOS, GNUstep, Objective-C++, UI, concurrency or cross-platform coverage. No sanitizers, leak detector, race analysis, allocation/disk-full/permission fault injection or asynchronous timing tests were run. Trusted authored fixtures and process bounds do not establish an arbitrary-code sandbox.
The pinned Atlas 0.11.0 evidence records 607 browser checks, 55 Python harness checks plus four unittest methods, 74 SQL checks, 515 shell checks across 71 runs, 99 TypeScript checks, 51 Data Formats checks, 119 C checks, 116 C++ checks, 97 Ruby checks, 97 Perl checks, 105 Swift harness checks and 97 Makefile harness checks, 145 awk checks, 145 sed checks, 161 jq checks, 157 XSLT checks, 150 Tcl checks and 161 Expect checks. These are separate measures. Tcl and Expect tests are dated 26 October 2026 on installed Tcl 8.5.9 / Expect 5.45 with Tcl 8.5.9 on macOS arm64. These old versions are recorded teaching evidence, not deployment recommendations. Tcl has 12 accepted programs and Expect has 12 accepted controllers; each has four expected evaluation failures, not static compilation passes. Tcl has nine scenarios, five expected nonzero; Expect has seven scenarios, four expected nonzero. Expect default controllers invoke 15 toy children, including two expected child failures; one scenario also expects a failed child. Controller success does not mean every child succeeds. The authoring release records 100 owned-runner regression checks and 109 independent runner checks separately. Only authored fixtures and retained native child handles are covered. Cooperative cleanup requires event-loop progress; outer-timeout child cleanup remains uncertain without complete wait receipts. The retired PID-inspection branch was not retried. No sign-ins, secrets, network or external application control are taught or tested by this pack. awk and sed are text-processing languages; their examples use fixed authored ASCII input and the C locale with installed awk 20200816 and macOS sed on one platform. jq and XSLT each have 12 accepted examples and four separately rejected programs. jq has 21 scenarios, including five contract errors and one no-result status; XSLT has 20 scenarios, including five terminating messages and one CLI parameter rejection. Expected nonzero outcomes are not successful programs. Tests dated 26 October 2026 used jq 1.7.1-apple and XSLT 1.0 with libxslt 1.1.35/libxml2 2.9.13, fixed trusted programs and tiny authored inputs in the C locale on macOS arm64. These old installed XML libraries are recorded learning environments, not recommendations for untrusted-document processing. No imports, external documents, DTDs, custom/external entities, extension functions or generated source are covered. Command flags and bounds are not a complete sandbox. Standalone XPath remains planned; supporting XPath 1.0 expressions are limited to these XSLT examples. These tests do not establish GNU-tool equivalence, Unicode behavior, arbitrary-script safety or cross-platform portability. Swift has 12 accepted programs and four expected static rejections; Makefile has 12 accepted default targets, four expected parser rejections, eight additional scenarios and one expected recipe failure. Makefile is build scripting, not a general-purpose language. The Swift and Makefile test execution dates remain 25 October 2026. awk and sed tests are dated 26 October 2026. Delivery verification does not replace or refresh test execution dates. TypeScript includes 12 accepted programs executed as JavaScript and nine intentionally invalid cases correctly rejected. Each C/C++ pack has 12 accepted programs run normally and with AddressSanitizer/UndefinedBehaviorSanitizer, plus four expected compiler rejections that are never executed. Ruby and Perl each have 12 syntax-accepted programs executed and four expected syntax rejections; rejected cases are not successful programs. Syntax checks may execute compile-time code and are not arbitrary-code sandboxes. Sanitizer results cover executed paths only; leak detection and allocation-failure injection were not tested and memory safety is not proved.
Tested environments are Chrome 155, CPython 3.9.6, SQLite CLI 3.54.0, macOS sh/Bash 3.2.57/Zsh 5.9, TypeScript 6.0.3, Node 24.18.0 Apple Clang 21.0.0, Ruby 2.6.10p210 and Perl 5.34.1, Apple Swift 6.4 in Swift 6 mode and GNU Make 3.81 on one arm64 macOS host. C uses a C17 subset; C++ uses a C++20 subset with libc++ 220106. Python 3.9.6 is unsupported upstream. Ruby 2.6 is end-of-life upstream; the recorded installed interpreter is not a recommended modern runtime. Data Formats uses installed Tomli 1.0.3 through a private fallback; the Python tomllib branch was not run. No new-installation recommendation, complete language/format conformance, schema certification, hardened untrusted XML parsing or general-purpose execution sandbox is established. Other platforms, browsers and screen readers remain unverified. The 145 official references belong to the saved Atlas review, not fresh website-time verification.