Chapter 6

Source File Organization

So far, every project we’ve talked about has had all its source code crammed into its main.m file. The main() function and all the @interface and @implementation sections for our classes are piled into the same file. That structure’s fine for small programs and quick hacks, but it doesn’t scale to larger projects. As your program gets bigger, you’ll have a ponderous file to scroll through, making finding stuff harder.

Back in your school days (assuming you’re finished with them), you didn’t put every term paper into the same word processing document (assuming you had word processors). You kept each paper in its own document, with a descriptive name. Likewise, it’s a good idea to split your program’s source ...

Get Learn Objective-C on the Mac: For OS X and iOS, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.