Sample Code

Apple provides plenty of sample code projects. You can view the code directly in the documentation window; sometimes this will be sufficient, but you can see only one class implementation or header file at a time, so it’s difficult to get an overview. The alternative is to open the sample code project in Xcode.

When you look at a sample code page from your browser, there’s a button that reads Download Sample Code. In fact, the sample code may already be on your computer. When you look at the same sample code page in the documentation window, the same button will read Open Project. The sample code on your hard disk is zipped, so even if the code is already on your computer, you are first asked to specify a “download folder” in which to save the unzipped project folder. This policy of keeping the sample code projects zipped on your hard disk is a good one, as it prevents you from accidentally altering the original, and you are free to experiment with the unzipped copy.

Warning

If a sample code project was linked against the frameworks of an older SDK that isn’t installed on your computer, you won’t be able to build and run the project, and features that depend on indexing won’t work. This situation is easy to detect and easy to fix. The chief sign is that the project will be described in the Project navigator with the words “missing base SDK,” and the Issue navigator will show a Target Integrity warning. To solve the problem, click that issue in the Issue navigator to edit ...

Get Programming iOS 4 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.