Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Tips for searching Headers, APIs and ADC reference material.
Q: I'm having a hard time tracking down the meaning of some error codes being generated by my application. What are some quick ways to find these codes in the system headers or documentation?
A: I'm having a hard time tracking down the meaning of some error codes being generated by my application. What are some quick ways to find these codes in the system headers or documentation?
There are a number of ways to search for reference material on the system. You can also set up your development environment to make searching through system headers or sample code directories easier in the future.
As an example, let us assume you're searching for the meaning of a -8960
error.
Xcode Documentation Search
Xcode includes its own documentation window. Use this window to view the technical documentation and other resources distributed as part of the ADC Reference Library.
To open Xcode’s documentation window, choose the Help > Documentation menu item as shown in Figure 1.

From here you have several ways to find documentation: Browse documentation by title and category, search for symbol names, perform a full-text search for a word or phrase, an API search, and so on.
For example, to find the definition of the error code -8960
, select Reference Library in the Search Groups list and select Full-Text Search from the pull-down menu of the search field. The results of this search are shown in Figure 2.

For a detailed description of how to best use Xcode's documentation search features see Viewing Documentation in the Xcode Workspace Guide.
Spotlight Your Headers
You can set up Spotlight to enable you to search developer header files or any additional folders you may have associated with your developer environment.
Use the mdimport command to import metadata from files or file system hierarchies.
Here's how to have Spotlight index additional folders such as /usr/include
, /usr/local/include
and /System/Library/Frameworks
.
$ mdimport /usr/include $ mdimport /usr/local/include $ mdimport /System/Library/Frameworks |

Using Terminal
There are of course a number of ways to search for items solely from the command line as well. While full coverage of this topic is beyond the scope of this Q&A, here are a couple of interesting ways to use find along with xargs and grep to perform searches.
Create aliases of these commands so they can easily be used from the command line.
afind "find . -type f -print0 | xargs -0 grep -H --" xfind "find . -name \"*.[cshmCSH]\" -print0 | xargs -0 grep -H --" |
% alias xfind="find . -name \"*.[cshmCSH]\" -print0 | xargs -0 grep -H --"
You can also learn more about find, xargs and grep from the Mac OS X Man pages.


As you can see from the above results, this error code is located in the file MacErrors.h
. If you know the name of a specific file that contains the information you're interested in but you aren't sure where to find it, use the locate command to find all pathnames matching the specified pattern.

Document Revision History
Date | Notes |
---|---|
2009-02-13 | Editorial Update |
2006-04-27 | New document that presents a number of different ways to search for APIs and reference material on the system. |
Copyright © 2009 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2009-02-13