• No results found

How To Use Ios 5

N/A
N/A
Protected

Academic year: 2021

Share "How To Use Ios 5"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

The Brand New Stuff

In 2007, the late Steve Jobs took the stage at Macworld and proclaimed that software running on iPhone was at least fi ve years ahead of the competition. Since its initial release, Apple has been iterating the operating system year after year, and has even added two new devices, the iPad and Apple TV, to the list of products capable of running it. As the operating system was customized to run on more devices than just the iPhone, it was rebranded as iOS. Today, it’s almost 5 years old, and iOS 5 is easily the biggest update to iOS since the original launch, possibly making the software fi ve years ahead of the competition again.

This book is about programming with iOS 5. Targeting intermediate to advanced iOS developers, this book, unlike most others, covers advanced topics of iOS development. Rather than learning about frameworks and the features available on the iOS SDK, you learn about how to make the best use of those features to help push your apps to the next level. This chapter briefl y describes the new features covered in detail in the book and tells you the chapters in which they are discussed.

The History of iOS

The second version, iPhone OS 2, was the fi rst to have a public SDK. From then on, with every release of the operating system, Apple introduced several major features and a lot more minor API changes. This section briefl y describes the history of the iOS. The remaining sections in the chapter provide an overview of what’s new in iOS 5.

iPhone OS 3 brought Core Data from Mac to iPhone. Other additions include Apple Push Notifi cation Service, External Accessory Kit, In App Purchases through the StoreKit.framework, in app email sheets, the MapKit.framework that allows developers to embed Google Maps into their apps, read-only access to the iPod library, and keychain data sharing. OS 3.1 added video editor support, a minor update. iPhone OS 3.2 added Core Text and gesture recognizers, fi le sharing, and PDF generation support, another minor (yet so major) update. OS 3.2 also added a whole new product, iPad, support for developing apps that run on iPad, and universal apps that run on iPad (3.2) and iPhone (3.1.3). 3.2 was iPad only and didn’t run on iPhone or iPod touch devices.

iPhone OS 4 (rebranded as iOS 4) introduced much-awaited multitasking support, local notifi cations, read-only access to calendar (Event Kit framework, EventKit.framework), blocks, Grand Central Dispatch (GCD), in app message composer sheets (SMS), and Retina display support. This version was iPhone only and didn’t support developing apps for iPad. A minor update, iOS 4.2, unifi ed iPhone and iPad operating systems.

(2)

What’s New

iOS 5 introduces several important features like iCloud, Automatic Reference Counting (ARC), Storyboards, built-in Twitter framework, and several other mbuilt-inor features. The next few sections built-introduce you to the key features added to iOS 5 and the chapters in which they are discussed in detail and where I provide guidance about how to push your apps to the next level.

iCloud

iCloud is a new cloud service provided by Apple. iCloud diff ers from competing similar off erings in that it’s more a cloud-based service than cloud-based storage. Developers have been using third-party services for synchronizing data across multiple devices. Dropbox is the most popular of these services; however, even Dropbox API version 0 (the latest version as of this writing), doesn’t support confl ict handling, something that’s critical for data integrity. While Dropbox has confl ict resolution, it’s not exposed to developers via their API. iCloud, on the other hand, supports fi le storage and has confl ict resolution built into the iOS 5 SDK.

iCloud also supports storing key-value data on the cloud, which is good enough for apps that need settings and other similar data to be kept in sync.

iCloud is not just a hard disk on the cloud. Think of iCloud as a cloud-based service that just happens to support data storage.

iOS 5 adds several new APIs for adding iCloud support:

■ UIDocument (very similar to its kin, NSDocument, on Mac)

■ UIManagedDocument, for managing your Core Data storage

■ Additions to NSFileManager to move and restore fi les from iCloud iCloud is covered in detail in Chapter 17.

LLVM 3.0 Compiler

LLVM (Low Level Virtual Machine) is a new compiler project partly funded by Apple. While technically not a part of iOS 5, developers should be equipped with the knowledge of the new features available in LLVM. Improved auto complete and speedier compilation are just a part of LLVM’s new features. In Chapter 2 you learn about the features of LLVM and how LLVM augments Xcode 4’s features.

Automatic Reference Counting

Another important feature of iOS 5 is Automatic Reference Counting (ARC). It is a compiler-level feature provided by the new LLVM compiler. This means that you can use it without increasing the minimum SDK support to iOS 5. ARC can be used in apps targeting iOS 4 onward, and Xcode 4.2 also provides support for migrating your code to use ARC using the Convert to Objective-C ARC tool. With the new LLVM compiler slowly becoming mainstream, ARC will supercede the current retain/release memory management.

(3)

Automatic Reference Counting is not like garbage collection off ered on Mac OS X from version 10.5 (Leopard). Garbage collection is automatic memory management. This means that developers don’t have to write a matching release for every retain statement. The compiler automatically inserts them for you.

ARC adds two new lifetime qualifi ers—strong and weak—and it also imposes new rules, such as that you can no longer invoke release, retain on any object. This applies to custom dealloc methods as well. When using ARC, your custom dealloc methods should only release resources (fi les or ports) and not instance variables. ARC is covered in detail in Chapter 3.

Storyboards—Draw Your Flow

Storyboards is a new way to design your user interface. Prior to iOS 5 you used Interface Builder nib fi les to defi ne your UI one view controller at a time. With Storyboards, you can defi ne in one fi le the complete UI fl ow of your app, including interaction among the diff erent view controllers.

You can use Storyboards to defi ne all view controllers in your app. You don’t have to create multiple Storyboards or worry about performance. The Interface Builder build tool automatically splits your storyboard fi le into parts and loads it individually at runtime without aff ecting performance.

On iOS 5, storyboards replace MainWindow.xib nib fi le (and possibly every other view controller’s nib fi le). The new project template in Xcode 4.2 helps in creating storyboards. You can also add a storyboard to your old projects and optionally make it the main storyboard by adding an entry to the Info.plist fi le.

Storyboards, unlike ARC, is an iOS 5-specifi c feature, and using Storyboards means that you need to raise your minimum supported OS to iOS 5.

You will learn more about storyboards in Chapter 5.

UIKit Customization—Appearance Proxy

Apple (and even Microsoft) has always been against UI customization, or theming. Its reasoning is that theming makes it diffi cult for users to understand the user interface. The Web, on the other hand, has made a huge revolution on this front and this has had an eff ect on the latest release of iOS as well. Beginning with iOS 5, some native apps like Reminders get some rich customization. With iOS 5, most properties of UIKit elements can be customized. This includes backgroundColor, tintColor, and a lot more. Customization is supported by a UIView subclass if it implements the UIAppearance protocol. The protocol also allows customization based on the contained view. For example, you can have a diff erent tint when a custom view of yours is within a navigation bar.

(4)

Twitter Framework and Accounts Framework

iOS 5 integrates Twitter experience right into the OS. This means sending a tweet from your app is as easy as sending an email using an in app email sheet. The framework also handles authentication for you, which means you no longer need to do the oAuth/xAuth authentication yourself. Twitter framework on iOS 5 integrates with Accounts framework to provide account authentication. As of this writing, Twitter is the only third-party authentication system supported natively on iOS 5. But, by looking at the decoupled design of Twitter framework and Accounts framework, there is a possibility that additional services might be introduced later on. While there are some advantages of using these frameworks, it’s still an iOS 5-specifi c feature, which means that using it requires you to limit your app to devices running iOS 5 and later. Additionally, when you send out a tweet through iOS, you will not be able to customize the sender (via text). As such, your tweet will be sent as “via iOS.” (See Figure 1-1.)

© Twitter 2011

Figure 1-1 Screenshot from Twitter.com showing the “via” text

When you create a new application on Twitter, you can name it so when you tweet using this application’s credentials, its name shows up in the “via” text. The built-in Twitter.framework on iOS 5 doesn’t allow setting this text, so if you are considering using Twitter for increasing your brand’s reach, you may have to evaluate branding versus ease of development.

Adding Twitter experience to your app with the new Twitter.Framework is as easy as sending an in app email. This diff ers from an app email in one aspect. Instead of providing a delegate callback, the TWTweetComposeViewController of Twitter.Framework provides a completionHandler. Chapter 16 shows you an example of this in action.

Other New Features

In addition to the “big” features discussed in the preceding sections, iOS 5 also adds several other features, including dedicated support for magazine apps, a native image processing library, AirPlay mirroring support, and new controls added to UIKit.framework.

Newsstand Kit

Newspaper or magazine apps can make use of the NewsstandKit.framework to deliver digital content. Although it was technically possible to do something similar with iOS 4, iOS 5 introduces several new APIs to enable content for the latest release to be downloaded in the background. Additionally it also enables

(5)

publishers to provide a cover art image (front cover) for their magazine instead of an icon. Apps developed using this framework appear within the Newsstand app and display the cover art instead of the app icon.

Core Image for Image Processing

Camera apps can use features in Core Image to apply image processing fi lters. The classes CIImage and CIFilter add basic image-editing functions like cropping, rotation (affi ne transform), and color inversion, to advanced features like gamma correction, white point adjustment, false color, sepia toning, temperature and tint correction, and many more that would be present in any entry-level image editor. This feature of iOS 5 will be tremendously useful for camera-enhancement apps that compete with apps like Instagram or Camera+. iPhone camera is already the most popular camera on Flickr. This framework will take it even further.

Core Image for Feature Detection

Core Image has another important element: feature detection. At WWDC 2011, Apple demonstrated a feature of Photo Booth that tracks the location of a face and adorns it with birds circling the head. With Core Image, you can add such features with very little programming eff ort. The class CIDetector has a convenient featuresInImage: method that returns a list of CIFeature objects detected in the given image. Core Image is discussed in Chapter 6.

Other Minor Enhancements

iOS 5 adds many other minor enhancements like AirPlay video support, mirroring (which can be disabled by your app if you are showing protected content); better document support; improvements in data protection (Chapter 11); a new control, UIStepper; capability to add a password entry fi eld to the UIAlertView just like the AppStore password prompt; a new UIPageViewController for creating page curl eff ects like iBooks; and much more. All these major and minor enhancements together make iOS 5 the biggest enhancement since its inception.

Summary

Adoption rates of iOS have always been way ahead of the competition. A couple of years ago, when iPhone OS 3.0 was launched, adoption rates were partly hindered on iPod touch because the upgrade cost $10. However, Apple soon made it free and adoption rates increased. Similarly, when Apple released iOS 4, the adoption rate was initially slow because of performance issues on older phones such as iPhone 3G and the original iPhone (and equivalent iPod touches). Some features—mainly multitasking—were also not available for older devices. Nevertheless, the latest iOS usually gets adopted on more than 90 percent of devices within the fi rst two months of launch. With iOS 5, adoption rates should be the fastest ever for the following reasons. First, the update is free for all devices, unlike iPhone OS 3. Second, unlike iOS 4, iOS 5 doesn’t make older devices (the iPhone 3GS) run slower. Finally, for end users, cleaner notifi cations, iTunes wi-fi sync, and iMessage are killer features that should accelerate iOS 5 adoption.

All this means that you should start using every iOS 5 feature as soon as possible to get your app to shine in all its glory. Features like iCloud and UIKit customizations alone should be reason enough to update your apps to iOS 5. That said, the next chapters start you on your iOS 5 journey.

(6)

Further Reading

Apple Documentation

The following documents are available in the iOS Developer Library at developer.apple.com or through the Xcode Documentation and API Reference.

iCloud

What’s New in iOS 5 Twitter Framework Accounts Framework

Other Resources

How is a fi le confl ict detected using the API - Dropbox forums http://forums.dropbox.com/topic.php?id=40492

References

Related documents

MPSJ’s decision to launch the bio Mass town concept with the Serdang Biomass Town Project together with MPSJ Bandar Bukit Puchong Integrated Biomass Centre

We supplement this result by showing that if the connectivity graph of a Markov chain is a cycle, then there is an Ω (n 2 ) lower bound for the mixing time.. This is the same order

If a fighter has a Strength score of 13 or more, the character gains a bonus to Experience Points earned in every adventure.. Hit Dice: An eight-sided die (Id8) is used to determine

= 15 Contact Hours = 15 Contact Hours = 15 Contact Hours = 7.5 Contact Hours or other accepted activities PU Module Contact Hours Continuing Education Professional Practice

When we calibrate the model with the estimated wage processes, the optimal size of government insurance programs is 3 percent of labor income in Sweden for our baseline

You will learn how to secure the network using Cisco IOS and CatOS security features, configure the Cisco IOS Firewall, implement secure tunnels, and complete a security audit..

It is based on the reduction of a molecular graph by excising the bond in question a nd other bonds for which a unique assignment of bond character is

The important features of the SOCS Wayfinder application include the extensibility to iOS and other platforms as a result of the technology used, ability to incorporate QR codes