iOS 4.2
This article summarizes the key developer-related features introduced in iOS 4.2. This version of the operating system runs on all iOS-based devices. In addition to describing the key new features, this article lists the documents that describe those features in more detail.
For the latest updates and information, you should also see iOS 4.2 Release Notes. For the complete list of new APIs added in iOS 4.2, see iOS 4.2 API Diffs.
Printing
iOS now incorporates support for wireless printing from iPhone and iPad applications. For the most part, the objects provided by UIKit do all of the heavy lifting associated with printing. They manage the printing interfaces, work with your application to render the printable content, and handle the scheduling and execution of print jobs on the printer.
Print jobs submitted by your application are handed off to the printing system, which manages the actual printing process. Print jobs from all applications on a device are queued and printed on a first-come, first-served basis. Users can get the status of print jobs from the Print Center application and can even use that application to cancel print jobs. All other aspects of printing are handled for you automatically by the system.
To simplify the printing process, UIKit provides automatic support for some types of content to make printing easier. Specifically, applications provide printable content in one of three ways:
An application can hand images or PDF content directly to UIKit and let it manage the printing of those items.
An application can use print formatter objects to lay out specific types of content over multiple pages. UIKit provides print formatters for plain text, HTML text, and some system views (web views, text views, and map views).
An application can choose to render the content itself using a print page renderer object. This option gives you the most control over your printed content but also lets you use print formatters to assist with the layout of parts of your content.
For information about how to incorporate the new printing support into your applications, see “Printing” in Drawing and Printing Guide for iOS.
AirPlay
AirPlay is a technology that lets your application stream audio to Apple TV and to third-party AirPlay speakers and receivers. AirPlay support is built in to the AV Foundation framework and the Core Audio family of frameworks. Any audio content you play using these frameworks is automatically made eligible for AirPlay distribution. Once the user chooses to play your audio using AirPlay, it is routed automatically by the system.
For information on how to play audio content, see Multimedia Programming Guide.
Core MIDI
The Core MIDI framework (CoreMIDI.framework) provides a standard way to communicate with MIDI devices, including hardware keyboards and synthesizers. You use this framework to send and receive MIDI messages and to interact with MIDI peripherals connected to an iOS-based device using the dock connector or network.
For more information about using this framework, see Core MIDI Framework Reference.
Weak Linking Support
Applications that link against iOS SDK 4.2 or later can now take advantage of new support for determining the availability of Objective-C classes. System frameworks now tag their classes with availability information that the compiler can use to link weakly to those classes as needed. This new tagging mechanism simplifies the code you need to use to do runtime checking for the availability of the class. Whereas previously, you needed to use the NSClassFromString function to determine whether a class was present, now you can simply check for the existence the class directly using code similar to the following:
if ([UIPrintInteractionController class]) |
{ |
// Create an instance of the class and use it. |
} |
else |
{ |
// The print interaction controller is not available. |
} |
In order to use this feature, you must do the following:
Build your project using LLVM and Clang. (The standalone GCC compiler does not currently support this feature.)
Set your project’s deployment target to iOS 3.1 or later.
Change the linking option for each framework you want to link weakly. To do this, open an inspector for your application target and go to the inspector’s General tab to view the list of frameworks and libraries linked against the target. For frameworks you want to link weakly, change the value in the Type column from Required to Weak.
If the deployment target for your application is set to a version of iOS that does not contain a given framework (because it was introduced in a later version), set the link type of that framework to Weak. For most other frameworks, you should leave the link type set to Required.
For information about how to perform runtime availability checks for classes and methods, see SDK Compatibility Guide.
Framework Enhancements
The following sections highlight the significant changes to frameworks and technologies in iOS 4.2. For a complete list of all new interfaces available in the system, see iOS 4.2 API Diffs.
Core Location
The Core Location framework includes new interfaces for determining whether a device is authorized to use location services and for detecting changes in the current authorization status. For more information about how to use Core Location in your application, see Location Awareness Programming Guide.
Game Kit
The Game Kit framework includes a new GKFriendRequestComposeViewController class, which you can present from your application and use to invite friends to play a game. For more information about how to use Game Kit in your application, see Game Center Programming Guide.
iAd
The iAd framework now supports banner ads sized appropriately for iPad devices. For more information about how to incorporate ads into your applications, see iAd Programming Guide.
Media Player
The Media Player framework includes the following enhancements:
The interface presented by the
MPVolumeViewclass now includes a control for routing audio content to AirPlay–enabled devices.The
MPMediaItemandMPMediaItemCollectionclasses now descend from a common ancestor class:MPMediaEntity. This change in hierarchy allows you to create collections that include both items and other collections.Persistent IDs for more collection types are now available.
Media queries now provide more information about how media items are grouped together.
For more information about the classes of the Media Player framework, see Media Player Framework Reference.
UIKit
The UIKit framework includes the following enhancements
New accessibility constants allow “scroll by page” capabilities using VoiceOver.
New classes to support printing; see “Printing”
The
UIDeviceclass now provides theplayInputClickmethod for playing the input-click sound directly.Application delegates can now use the
application:openURL:sourceApplication:annotation:method to receive information about URLs that are opened while the application is running in the background.The
UITextInputModeclass now exposes the language in use for inputting text.The
UIDocumentInteractionControllerclass supports printing with the help of its delegate object.
For more information about the classes of the UIKit framework, see UIKit Framework Reference.
© 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-01-28)