Apple provides many Macintosh application development frameworks (code libraries) that your app can call to perform the thousands of operations in OS X. Many of these frameworks, such as the PDF Kit, are composed of Objective-C classes, from which your app can create and use objects within your applications. However, some of these frameworks are just libraries of functions that your app can execute.

For instance, the CFNetwork framework is a set of functions that your app can use to perform fine-tuned network connections. The NSURL class provides a good set of basic network operations that are great for retrieving data using a URL. If your app requires more control over the network communications it initiates, you’ll have to use the CFNetwork framework and its functions. You could use the following code to prepare an HTTP request for transmission to a specific URL:

CFStringRef httpBody = CFSTR( "" );
CFStringRef headerFieldName = CFSTR( "Cookie" ); // add specific cookie to HTTP request
CFStringRef headerFieldValue = CFSTR( "loginID=my_user_name; password=my_password;" );
CFStringRef url = CFSTR( "" );
CFURLRef urlRef = CFURLCreateWithStrign( kCFAllocatorDefault, url, NULL );
CFStringRef requestMethod = CFSTR( "GET" );
CFHTTPMessageRef request = CFHTTPMessageCreateRequest( kCFAllocatorDefault, requestMethod, url, kCFHTTPVersion1_1 );
CFHTTPMessageSetBody( request, httpBody );
// add the cookie
CFHTTPMessageSetHeaderFieldValue( request, headerFieldName, headerFieldValue );
CFDataRef serializedHttpRequest = CFHTTPMessageCopySerializedMessage( request );

Once your code has the serialized request, your app can then open a write-stream in order to deliver the request to its destination.

All of the C-based Apple frameworks provide a set of functions for performing this type of lower-level programming. Your code will get more complicated, but Apple doesn't provide Objective-C classes for all its frameworks. If you really require the functionality available in one of those frameworks, this is the only way you can achieve your app’s goals. The following frameworks don't provide Objective-C classes:

  • Audio Toolbox

  • CFNetwork

  • Core MIDI

  • Core Text

  • Directory Service (such as LDAP and Open Directory)

  • Security

If you want to create apps that can take full advantage of the features of OS X, you need to be ready to support the use of non-Objective-C code libraries.