Core Services Layer
The Core Services layer contains 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.
High-Level Features
The following sections describe some of the key technologies available in the Core Services layer.
iCloud Storage
Introduced in iOS 5, iCloud storage lets your application write user documents and data to a central location and access those items from all of a user’s computers and iOS devices. Making a user’s documents ubiquitous using iCloud means that a user can view or edit those documents from any device without having to sync or transfer files explicitly. Storing documents in a user’s iCloud account also provides a layer of safety for that user. Even if a user loses a device, the documents on that device are not lost if they are in iCloud storage.
There are two ways that applications can take advantage of iCloud storage, each of which has a different intended usage:
iCloud document storage—Use this feature to store user documents and data in the user’s iCloud account.
iCloud key-value data storage—Use this feature to share small amounts of data among instances of your application.
Most applications will use iCloud document storage to share documents from a user’s iCloud account. This is the feature that users think of when they think of iCloud storage. A user cares about whether documents are shared across devices and can see and manage those documents from a given device. In contrast, the iCloud key-value data store is not something a user would see. It is a way for your application to share very small amounts of data (tens of kilobytes) with other instances of itself. Applications should use this feature to store noncritical application data, such as preferences, rather than important application data.

For an overview of how you incorporate iCloud support into your application, see iCloud Design Guide.
Automatic Reference Counting
Introduced in iOS 5, Automatic Reference Counting (ARC) is a compiler-level feature that simplifies the process of managing the lifetimes of Objective-C objects. Instead of you having to remember when to retain or release an object, ARC evaluates the lifetime requirements of your objects and automatically inserts the appropriate method calls at compile time.

ARC replaces the traditional managed memory model style of programming found in earlier versions of iOS. Any new projects you create automatically use ARC. And Xcode provides migration tools to help convert existing projects to use ARC. For more information about ARC itself, see Transitioning to ARC Release Notes.
Block Objects
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 their uses, see A Short Practical Guide to Blocks. For more information about blocks, see Blocks Programming Topics.
Data Protection
Introduced in iOS 4.0, data protection allows applications that work with sensitive user data to take advantage of the built-in encryption available on some devices. When your application designates a specific file as protected, the system stores that file on-disk in an encrypted format. While the device is locked, the contents of the file are inaccessible to both your application and to any potential intruders. However, when the device is unlocked by the user, a decryption key is created to allow your application to access the file.
In iOS 5 and later, data protection includes additional security levels for protected files. These levels let you access an open file even if the user locks the device and access a file after device boot and first unlock, even if the user subsequently locks the device again.
Implementing data protection requires you to be considerate in how you create and manage the data you want to protect. Applications must be designed to secure the data at creation time and to be prepared for access changes when the user locks and unlocks the device.
For more information about how to add data protection to the files of your application, see iOS App Programming Guide.
File-Sharing Support
Introduced in iOS 3.2, file-sharing support lets applications make user data files available via iTunes 9.1 and later. An application that declares its support for file sharing makes the contents of its /Documents directory available to the user. The user can then move files in and out of this directory as needed from iTunes. This feature does not allow your application to share files with other applications on the same device; that behavior requires the pasteboard or a document interaction controller object.
To enable file sharing for your application, do the following:
Add the
UIFileSharingEnabledkey to your application’sInfo.plistfile and set the value of the key toYES.Put whatever files you want to share in your application’s
Documentsdirectory.When the device is plugged into the user’s computer, iTunes displays a File Sharing section in the Apps tab of the selected device.
The user can add files to this directory or move files to the desktop.
Applications that support file sharing should be able to recognize when files have been added to the Documents directory and respond appropriately. For example, your application might make the contents of any new files available from its interface. You should never present the user with the list of files in this directory and ask them to decide what to do with those files.
For additional information about the UIFileSharingEnabled key, see Information Property List Key Reference.
Grand Central Dispatch
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, and monitoring signals and process events.
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.
In-App Purchase
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.
In iOS 6, support was added for content hosting and for purchasing iTunes content from inside your app. With content hosting, you can now store your downloadable content on Apple’s servers. With iTunes purchase, your app identifies the items you want to make available for purchase but the rest of the transaction is handled for you by Store Kit.
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.”
SQLite
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.
XML Support
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 library. 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.
Core Services Frameworks
The following sections describe the frameworks of the Core Services layer and the services they offer.
Accounts Framework
Introduced in iOS 5, the Accounts framework (Accounts.framework) provides a single sign-on model for certain user accounts. Single sign-on improves the user experience, because applications no longer need to prompt a user separately for login information related to an account. It also simplifies the development model for you by managing the account authorization process for your application. In iOS 5.0, applications can use this framework in conjunction with the Twitter framework to access a user’s Twitter account.
For more information about the classes of the Accounts framework, see Accounts Framework Reference.
Address Book Framework
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.
In iOS 6 and later, access to a user’s contacts requires explicit permission from the user. Apps must therefore be prepared for the user to deny that access. Apps are also encouraged to provide Info.plist keys describing the reason for needing access.
For information about the functions in the Address Book framework, see Address Book Framework Reference for iOS.
Ad Support Framework
Introduced in iOS 6, the Ad Support framework (AdSupport.framework) provides access to an identifier that apps can use for advertising purposes. This framework also provides a flag that indicates whether the user has opted out of ad tracking. Apps are required to read and honor the opt-out flag before trying to access the advertising identifier.
For more information about this framework, see Ad Support Framework Reference.
CFNetwork Framework
The CFNetwork framework (CFNetwork.framework) is a set of high-performance C-based interfaces that use 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. With the CFNetwork framework, you can:
Use BSD sockets
Create encrypted connections using SSL or TLS
Resolve DNS hosts
Work with HTTP servers, authenticating HTTP servers, 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.
Core Data Framework
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 in which 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
NSFetchedResultsControllerclass to manage results for table viewsManagement 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.
Core Foundation Framework
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 connected to.
For more information about this framework, see Core Foundation Framework Reference.
Core Location Framework
The Core Location framework (CoreLocation.framework) provides location and heading information to applications. For location information, the framework uses the onboard GPS, cell, or Wi-Fi radios to find the user’s current longitude and latitude. 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-based heading information on iOS-based devices that include a magnetometer.
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 how to use Core Location to gather location and heading information, see Location Awareness Programming Guide and Core Location Framework Reference.
Core Media Framework
Introduced in iOS 4.0, the Core Media framework (CoreMedia.framework) provides the low-level media types used by the AV Foundation framework. Most applications 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.
Core Motion Framework
The Core Motion framework (CoreMotion.framework) provides a single set of interfaces for accessing all motion-based data available on a device. The framework supports accessing both raw and processed accelerometer data using a new set of block-based interfaces. For devices with a built-in gyroscope, you can retrieve the raw gyro data as well as processed data reflecting the attitude and rotation rates of the device. You can use both the accelerometer and gyro-based data for games or other applications that use motion as input or as a way to enhance the overall user experience.
For more information about the classes and methods of this framework, see Core Motion Framework Reference.
Core Telephony Framework
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 (such as VoIP applications) 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.
Event Kit Framework
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.
In iOS 6, support was added for creating and accessing reminders on the user’s device. The reminders you create show up in the Reminders app along with ones created by the user. In addition, access to a calendar and reminder data requires explicit permission from the user. Apps must therefore be prepared for the user to deny that access. Apps are also encouraged to provide Info.plist keys describing the reason for needing access.
For more information about the classes and methods of this framework, see Event Kit Framework Reference. See also “Event Kit UI Framework.”
Foundation 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.
Mobile Core Services Framework
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.
Newsstand Kit Framework
Introduced in iOS 5, Newsstand provides a central place for users to read magazines and newspapers. Publishers who want to deliver their magazine and newspaper content through Newsstand can create their own iOS applications using the Newsstand Kit framework (NewsstandKit.framework), which lets you initiate background downloads of new magazine and newspaper issues. After you start a download, the system handles the download operation and notifies your application when the new content is available.
For information about the classes you use to manage Newsstand downloads, see Newsstand Kit Framework Reference. For information about how to use push notifications to notify your applications, see Local and Push Notification Programming Guide.
Pass Kit Framework
Introduced in iOS 6, Pass Kit uses web services, a new file format, and an Objective-C framework (PassKit.framework) to implement support for downloadable passes. Companies can create passes to represent items such as coupons, boarding passes, event tickets, and discount cards for businesses. Instead of carrying a physical representation of these items, users can now store them on their iOS device and use them the same way as before.
Passes are created by your company’s web service and delivered to the user’s device via email, Safari, or your custom app. The pass itself uses a special file format and is cryptographically signed before being delivered. The file format identifies relevant information about the service being offered so that the user knows what it is for. It might also contain a bar code or other information that you can then use to validate the card so that it can be redeemed or used.
For more information about Pass Kit and for information how to add support for it into your apps, see Passbook Programming Guide.
Quick Look Framework
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 for iOS.
Social Framework
Introduced in iOS 6, the Social framework (Social.framework) provides a simple interface for accessing the user’s social media accounts. This framework supplants the Twitter framework that was introduced in iOS 5 and adds support for other social accounts, including Facebook and Sina’s Weibo service. Apps can use this framework to post status updates and images to a user’s account. This framework works with the Accounts framework to provide a single sign-on model for the user and to ensure that access to the user’s account is approved.
For more information about the Social framework, see Social Framework Reference.
Store Kit Framework
Introduced in iOS 3, 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.
System Configuration Framework
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 whether 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 code project.
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)