The Core Services layer provides the fundamental system services that all applications use. Even if you do not use these services directly, many parts of the system are built on top of them.
The following sections describe some of the more common features you might want to support in your applications.
Introduced in iOS 4.0, block objects are a C-level language construct that you can incorporate into your C and Objective-C code. A block object is essentially an anonymous function and the data that goes with that function, something which in other languages is sometimes called a closure or lambda. Blocks are particularly useful as callbacks or in places where you need a way of easily combining both the code to be executed and the associated data.
In iOS, blocks are commonly used in the following scenarios:
As a replacement for delegates and delegate methods
As a replacement for callback functions
To implement completion handlers for one-time operations
To facilitate performing a task on all the items in a collection
Together with dispatch queues, to perform asynchronous tasks
For an introduction to block objects and how you use them, see A Short Practical Guide to Blocks. For more information about blocks, see Blocks Programming Topics.
Introduced in iOS 4.0, Grand Central Dispatch (GCD) is a BSD-level technology that you use to manage the execution of tasks in your application. GCD combines an asynchronous programming model with a highly optimized core to provide a convenient (and more efficient) alternative to threading. GCD also provides convenient alternatives for many types of low-level tasks, such as reading and writing file descriptors, implementing timers, monitoring signals and process events, and more.
For more information about how to use GCD in your applications, see Concurrency Programming Guide. For information about specific GCD functions, see Grand Central Dispatch (GCD) Reference.
Introduced in iOS 3.0, In App Purchase gives you the ability to vend content and services from inside your application. This feature is implemented using the Store Kit framework, which provides the infrastructure needed to process financial transactions using the user’s iTunes account. Your application handles the overall user experience and the presentation of the content or services available for purchase.
For more information about supporting in app purchase, see In App Purchase Programming Guide. For additional information about the Store Kit framework, see “Store Kit Framework.”
Applications that want to track the user’s position can do so using the interfaces of the Core Location framework. This framework takes advantage of all the available hardware radios (including Wi-Fi, cellular, and GPS where available) to report the user’s current location. Applications can use this information to tailor the information they deliver to the user or to implement specific features. For example, a social application might allow you to find other nearby users of the application and communicate with them.
For more information about using location services, see Location Awareness Programming Guide. For more information about the Core Location framework, see also “Core Location Framework.”
The SQLite library lets you embed a lightweight SQL database into your application without running a separate remote database server process. From your application, you can create local database files and manage the tables and records in those files. The library is designed for general purpose use but is still optimized to provide fast access to database records.
The header file for accessing the SQLite library is located in <iOS_SDK>/usr/include/sqlite3.h
, where <iOS_SDK> is the path to the target SDK in your Xcode installation directory. For more information about using SQLite, go to http://www.sqlite.org.
The Foundation framework provides the NSXMLParser
class for retrieving elements from an XML document. Additional support for manipulating XML content is provided by the libXML2
libraries. This open source library lets you parse or write arbitrary XML data quickly and transform XML content to HTML.
The header files for accessing the libXML2
library are located in the <iOS_SDK>/usr/include/libxml2/
directory, where <iOS_SDK> is the path to the target SDK in your Xcode installation directory. For more information about using libXML2
, go to http://xmlsoft.org/index.html.
The following sections describe the frameworks of the Core Services layer and the services they offer.
The Address Book framework (AddressBook.framework
) provides programmatic access to the contacts stored on a user’s device. If your application uses contact information, you can use this framework to access and modify the records in the user’s contacts database. For example, a chat program might use this framework to retrieve the list of possible contacts with which to initiate a chat session and display those contacts in a custom view.
For information about the functions in the Address Book framework, see Address Book Framework Reference.
The CFNetwork framework (CFNetwork.framework
) is a set of high-performance, C-based interfaces that provide object-oriented abstractions for working with network protocols. These abstractions give you detailed control over the protocol stack and make it easy to use lower-level constructs such as BSD sockets. You can use this framework to simplify tasks such as communicating with FTP and HTTP servers or resolving DNS hosts. Here are some of the tasks you can perform with the CFNetwork framework. You can:
Use BSD sockets
Create encrypted connections using SSL or TLS
Resolve DNS hosts
Work with HTTP, authenticating HTTP, and HTTPS servers
Work with FTP servers
Publish, resolve, and browse Bonjour services
CFNetwork is based, both physically and theoretically, on BSD sockets. For information on how to use CFNetwork, see CFNetwork Programming Guide and CFNetwork Framework Reference.
Introduced in iOS 3.0, the Core Data framework (CoreData.framework
) is a technology for managing the data model of a Model-View-Controller application. Core Data is intended for use in applications where the data model is already highly structured. Instead of defining data structures programmatically, you use the graphical tools in Xcode to build a schema representing your data model. At runtime, instances of your data-model entities are created, managed, and made available through the Core Data framework.
By managing your application’s data model for you, Core Data significantly reduces the amount of code you have to write for your application. Core Data also provides the following features:
Storage of object data in a SQLite database for optimal performance
A new NSFetchedResultsController
class to manage results for table views
Management of undo/redo beyond basic text editing
Support for the validation of property values
Support for propagating changes and ensuring that the relationships between objects remain consistent
Support for grouping, filtering, and organizing data in memory
If you are starting to develop a new application or are planning a significant update to an existing application, you should consider using Core Data. For an example of how to use Core Data in an iOS application, see Core Data Tutorial for iOS. For more information about the classes of the Core Data framework, see Core Data Framework Reference.
The Core Foundation framework (CoreFoundation.framework
) is a set of C-based interfaces that provide basic data management and service features for iOS applications. This framework includes support for the following:
Collection data types (arrays, sets, and so on)
Bundles
String management
Date and time management
Raw data block management
Preferences management
URL and stream manipulation
Threads and run loops
Port and socket communication
The Core Foundation framework is closely related to the Foundation framework, which provides Objective-C interfaces for the same basic features. When you need to mix Foundation objects and Core Foundation types, you can take advantage of the “toll-free bridging” that exists between the two frameworks. Toll-free bridging means that you can use some Core Foundation and Foundation types interchangeably in the methods and functions of either framework. This support is available for many of the data types, including the collection and string data types. The class and type descriptions for each framework state whether an object is toll-free bridged and, if so, what object it is bridged with.
For more information about this framework, see Core Foundation Framework Reference.
The Core Location framework (CoreLocation.framework
) lets you determine the current latitude and longitude of a device. The framework uses the available hardware to triangulate the user’s position based on nearby GPS, cell, or WiFi signal information. The Maps application uses this feature to show the user’s current position on a map. You can incorporate this technology into your own applications to provide position-based information to the user. For example, you might have a service that searches for nearby restaurants, shops, or facilities, and base that search on the user’s current location.
In iOS 3.0, support was added for accessing compass information on iOS–based devices that include suitable hardware.
In iOS 4.0, support was introduced for a low-power location monitoring service that uses cellular towers to track changes in the user’s location.
For information about the classes of the Core Location framework, see Core Location Framework Reference.
Introduced in iOS 4.0, the Core Media framework (CoreMedia.framework
) provides the low-level media types used by AV Foundation. Most applications should never need to use this framework, but it is provided for those few developers who need more precise control over the creation and presentation of audio and video content.
For more information about the functions and data types of this framework, see Core Media Framework Reference.
Introduced in iOS 4.0, the Core Telephony framework (CoreTelephony.framework
) provides interfaces for interacting with phone-based information on devices that have a cellular radio. Applications can use this framework to get information about a user’s cellular service provider. Applications interested in cellular call events can also be notified when those events occur.
For more information about using the classes and methods of this framework, see Core Telephony Framework Reference.
Introduced in iOS 4.0, the Event Kit framework (EventKit.framework
) provides an interface for accessing calendar events on a user’s device. You can use this framework to get existing events and add new events to the user’s calendar. Calendar events can include alarms that you can configure with rules for when they should be delivered.
For more information about the classes and methods of this framework, see Event Kit Framework Reference. See also “Event Kit UI Framework.”
The Foundation framework (Foundation.framework
) provides Objective-C wrappers to many of the features found in the Core Foundation framework, which is described in“Core Foundation Framework.” The Foundation framework provides support for the following features:
Collection data types (arrays, sets, and so on)
Bundles
String management
Date and time management
Raw data block management
Preferences management
URL and stream manipulation
Threads and run loops
Bonjour
Communication port management
Internationalization
Regular expression matching
Cache support
For information about the classes of the Foundation framework, see Foundation Framework Reference.
Introduced in iOS 3.0, the Mobile Core Services framework (MobileCoreServices.framework
) defines the low-level types used in Uniform Type Identifiers (UTIs).
For more information about the types defined by this framework, see Uniform Type Identifiers Reference.
Introduced in iOS 4.0, the Quick Look framework (QuickLook.framework
) provides a direct interface for previewing the contents of files your application does not support directly. This framework is intended primarily for applications that download files from the network or that otherwise work with files from unknown sources. After obtaining the file, you use the view controller provided by this framework to display the contents of that file directly in your user interface.
For more information about the classes and methods of this framework, see Quick Look Framework Reference.
Introduced in iOS 3.0, the Store Kit framework (StoreKit.framework
) provides support for the purchasing of content and services from within your iOS applications. For example, you could use this feature to allow the user to unlock additional application features. Or if you are a game developer, you could use it to offer additional game levels. In both cases, the Store Kit framework handles the financial aspects of the transaction, processing payment requests through the user’s iTunes Store account and providing your application with information about the purchase.
The Store Kit focuses on the financial aspects of a transaction, ensuring that transactions occur securely and correctly. Your application handles the other aspects of the transaction, including the presentation of a purchasing interface and the downloading (or unlocking) of the appropriate content. This division of labor gives you control over the user experience for purchasing content. You decide what kind of purchasing interface you want to present to the user and when to do so. You also decide on the delivery mechanism that works best for your application.
For information about how to use the Store Kit framework, see In App Purchase Programming Guide and Store Kit Framework Reference.
The System Configuration framework (SystemConfiguration.framework) provides the reachability interfaces, which you can use to determine the network configuration of a device. You can use this framework to determine if a Wi-Fi or cellular connection is in use and whether a particular host server can be accessed.
For more information about the interfaces of this framework, see System Configuration Framework Reference. For an example of how to use this framework to obtain network information, see the Reachability sample.
Last updated: 2010-07-08