The Core Services layer contains fundamental system services for apps. Key among these services are the Core Foundation and Foundation frameworks, which define the basic types that all apps use.
The following sections describe some of the high-level features available in the Core Services layer.
The Multipeer Connectivity framework provides peer-to-peer connectivity over Bluetooth. You can use peer-to-peer connectivity to initiate communication sessions with nearby devices. Although peer-to-peer connectivity is used primarily in games, you can also use this feature in other types of apps.
For information about how to use peer-to-peer connectivity features in your app, see Multipeer Connectivity Framework Reference.
iCloud storage lets your app write user documents and data to a central location. Users can then access those items from all of their computers and iOS devices. Making a user’s documents ubiquitous using iCloud means that users 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 users. 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 apps 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 app.
Most apps 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.) Users care about whether documents are shared across devices and whether they can see and manage those documents from a given device. In contrast, the iCloud key-value data store is not something users would see. Instead, it is a way for your app to share very small amounts of data (tens of kilobytes) with other instances of itself. Apps should use this feature to store noncritical app data, such as preferences, rather than important app data.
For an overview of how you incorporate iCloud support into your app, see iCloud Design Guide.
Automatic Reference Counting
Automatic Reference Counting (ARC) is a compiler-level feature that simplifies the process of managing the lifetimes of Objective-C objects. Instead of your 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, seeTransitioning to ARC Release Notes.
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
Data protection allows apps that work with sensitive user data to take advantage of the built-in encryption available on some devices. When your app 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 app and to any potential intruders. However, when the device is unlocked by the user, a decryption key is created to allow your app to access the file. Other levels of data protection are also available for you to use.
Implementing data protection requires you to be considerate in how you create and manage the data you want to protect. Apps 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 app, see iOS App Programming Guide.
File-sharing support lets apps make user data files available in iTunes 9.1 and later. An app 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 app to share files with other apps on the same device; that behavior requires the pasteboard or a document interaction controller object.
To enable file sharing for your app, do the following:
UIFileSharingEnabledkey to your app’s
Info.plistfile, and set the value of the key to
Put whatever files you want to share in your app’s
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.
Apps that support file sharing should be able to recognize when files have been added to the
Documents directory and respond appropriately. For example, your app 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
Grand Central Dispatch (GCD) is a BSD-level technology that you use to manage the execution of tasks in your app. 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.
In-App Purchase gives you the ability to vend app-specific content and services and iTunes content from inside your app. 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 app handles the overall user experience and the presentation of the content or services available for purchase. For downloadable content, you can host the content yourself or let Apple’s servers host it for you.
The SQLite library lets you embed a lightweight SQL database into your app without running a separate remote database server process. From your app, 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, see the SQLite Software Library.
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, see the documentation for libxml2.
Core Services Frameworks
The following sections describe the frameworks of the Core Services layer and the services they offer.
The Accounts framework (
Accounts.framework) provides a single sign-on model for certain user accounts. Single sign-on improves the user experience by eliminating the need to prompt the user separately for multiple accounts. It also simplifies the development model for you by managing the account authorization process for your app. You use this framework in conjunction with the Social framework.
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 a user’s contacts database. If your app uses contact information, you can use this framework to access and modify that information. 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 for iOS.
Ad Support Framework
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.
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
Core Data Framework
The Core Data framework (
CoreData.framework) is a technology for managing the data model of a Model-View-Controller app. Core Data is intended for use in apps 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 app’s data model for you, Core Data significantly reduces the amount of code you have to write for your app. Core Data also provides the following features:
Storage of object data in a SQLite database for optimal performance
NSFetchedResultsControllerclass 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 app or are planning a significant update to an existing app, you should consider using Core Data. For an example of how to use Core Data in an iOS app, 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 apps. This framework includes support for the following:
Collection data types (arrays, sets, and so on)
Date and time management
Raw data block 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 apps. 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 apps 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. Core Location also provides the following capabilities:
Access to compass-based heading information on iOS devices that include a magnetometer
Support for region monitoring based on a geographic location or Bluetooth beacon
Support for low-power location-monitoring using cell towers
Collaboration with Map Kit to improve the quality of location data in specific situations, such as when driving
Core Media Framework
The Core Media framework (
CoreMedia.framework) provides the low-level media types used by the AV Foundation framework. Most apps 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 the gyro-based data for games or other apps that use motion as input or as a way to enhance the overall user experience. For devices with step-counting hardware, you can access that data and use it to track fitness-related activities.
For more information about the classes and methods of this framework, see Core Motion Framework Reference.
Core Telephony Framework
The Core Telephony framework (
CoreTelephony.framework) provides interfaces for interacting with phone-based information on devices that have a cellular radio. Apps can use this framework to get information about a user’s cellular service provider. Apps interested in cellular call events (such as VoIP apps) 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
The Event Kit framework (
EventKit.framework) provides an interface for accessing calendar events on a user’s device. You can use this framework to do the following:
Get existing events and reminders from the user’s calendar
Add events to the user’s calendar
Create reminders for the user and have them appear in the Reminders app
Configure alarms for calendar events, including setting rules for when those alarms should be triggered
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)
Date and time management
Raw data block management
URL and stream manipulation
Threads and run loops
Communication port management
Regular expression matching
For information about the classes of the Foundation framework, see Foundation Framework Reference.
For information about the classes of this framework, see the header files.
Mobile Core Services Framework
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.
Multipeer Connectivity Framework
The Multipeer Connectivity framework (
MultipeerConnectivity.framework) supports the discovery of nearby devices and the direct communication with those devices without requiring Internet connectivity. This framework makes it possible to create multipeer sessions easily and to support reliable in-order data transmission and real-time data transmission. With this framework, your app can communicate with nearby devices and seamlessly exchange data.
The framework provides programmatic and UI-based options for discovering and managing network services. Apps can integrate the
MCBrowserViewController class into their UI to display a list of peer devices for the user to choose from. Alternatively, you can use the
MCNearbyServiceBrowser class to look for and manage peer devices programmatically.
For more information about the interfaces of this framework, see Multipeer Connectivity Framework Reference.
Newsstand Kit Framework
The Newsstand app 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 apps 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 app 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 apps, see Local and Push Notification Programming Guide.
Pass Kit Framework
The Passbook app provides users with a place to store 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. The Pass Kit framework (
PassKit.framework) provides the Objective-C interfaces you need to integrate support for these items into your apps. You use this framework in combination with web interfaces and file format information to create and manage the passes your company offers.
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, using a special file format, is cryptographically signed before being delivered. The file format identifies relevant information about the service being offered so that the user knows what the service 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
The Quick Look framework (
QuickLook.framework) provides a direct interface for previewing the contents of files that your app does not support directly. This framework is intended primarily for apps 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.
Safari Services Framework
The Safari Services framework (
SafariServices.framework) provides support for programmatically adding URLs to the user’s Safari reading list. For information about the class provided by this framework, see the framework header files.
The Social framework (
Social.framework) provides a simple interface for accessing the user’s social media accounts. This framework supplants the Twitter framework and adds support for other social accounts, including Facebook, Sina Weibo, and others. 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
The Store Kit framework (
StoreKit.framework) provides support for the purchasing of content and services from within your iOS apps, a feature known as In-App Purchase. For example, you can use this feature to allow the user to unlock additional app features. Or if you are a game developer, you can 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 app with information about the purchase.
Store Kit focuses on the financial aspects of a transaction, ensuring that transactions occur securely and correctly. Your app 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 app.
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.