Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Objective-C.Programming.pdf
Скачиваний:
14
Добавлен:
21.02.2016
Размер:
8.64 Mб
Скачать

Chapter 16 Developer Documentation

Sample Code: These are small, complete projects that demonstrate how Apple expects its technology to be used. For example, there is a WeatherMap project that shows how to make custom annotations on iOS map views.

Release Notes: Every time a new version of Mac OS or iOS comes out, it is accompanied by a set of release notes. The release notes tell developers what has changed since the last version.

Technical notes, Articles, Coding How-to’s, and Technical Q&As,: These are bite-sized documents that address specific issues.

You can browse the documentation, but there is a lot of it. More commonly, you will access the documentation via search.

Reference pages

At the top of the lefthand pane in Organizer, click the button to bring up the search panel. Type NSArray into the search field, and the search results will appear below the search field. In the Reference section, click on NSArray to see the reference page for NSArray.

Figure 16.2 NSArray reference page

It would be difficult to overstate how important these reference pages will be to you and how important they are for programmers of all levels. Apple has worked really hard to create huge libraries of code for your convenience. You will learn about these libraries primarily through reference pages. As you go through this book, take a moment to look up the reference pages for new classes as you use them

94

Reference pages

and see what else they can do. You can also search for methods, functions, constants, and properties by name. (You’ll learn about properties in Chapter 17.) The more comfortable you get using these pages, the faster your development will go.

At the top of the class reference for NSArray, you can learn several things about the class. It inherits from NSObject. (More about this soon in Chapter 18.) It conforms to several protocols (which we’ll discuss in Chapter 25). It is part of the Foundation framework and has shipped with every version of Mac OS X and every version of iOS.

At the end of the header, there is a list of guides that discuss NSArray and sample code that shows off the capabilities of NSArray. Click on Collections Programming Topics to open that guide.

Figure 16.3 Collections Programming Topics

This particular guide discusses the collection classes (including NSArray and NSMutableArray). Unlike the class reference, a guide is a pleasant read, in which ideas are introduced in a sensical order.

Now use the back button at the top of the document pane to go back to the NSArray reference page. Curious about what other messages you can send to an NSArray? Scroll down the reference page and find the list of methods that NSArray implements. Say you’re looking for a way to check if an array contains a particular item. In that case, you’d run across the containsObject: method and read its description:

95

Chapter 16 Developer Documentation

Figure 16.4 Reference for containsObject:

Now you know everything you need to know to send this message in your code.

Quick Help

But there’s an easier way to get from the editor where you’re writing code to the wellspring of knowledge in the documentation. Close the Organizer and return to your DateList project.

In main.m, find the line that includes [dateList addObject:now]. Hold down the Option key and click on addObject:. The Quick Help window will appear with the information about that method:

96

Quick Help

Figure 16.5 Quick Help window

Notice that there are links in the Quick Help window. If you click a link, it will open the appropriate documentation in the Organizer. Handy, right?

If you want to see that Quick Help all the time, you can open it as a pane in Xcode.

In the upper-right corner of the Xcode window, find a segmented control called View that looks like and indicates Xcode’s lefthand, bottom, and righthand panes. Selecting and de-selecting these

buttons will hide and show the respective panes.

The lefthand pane, which you’ve used plenty by now, is called the navigator. The bottom pane, which you’ve also seen, includes the console and is called the debug area. The righthand pane is called Utilities. Click the righthand View button to reveal Utilities. At the top of Utilities, click the button to reveal the Quick Help pane.

This pane will show help for the text selected in the editor. Try it: just select the word “NSMutableArray” in the editor:

97

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]