31,19 €
Building on the phenomenal success of its predecessor iOS 5 includes over 200 new user features as well as an updated SDK containing over 1,500 new APIs. iOS 5 looks set to reinforce the iPhone's dominance in the smartphone market.
iOS 5 Essentials will help you learn how to build simple, yet powerful iOS 5 applications incorporating iCloud Storage, Twitter, Core Image and Newsstand integration.
You will start by learning about what's new in iOS 5. You'll look at the iCloud Storage APIs, Automatic Reference Counting, Twitter and AirPlay integration, how to use the various Core Image filters using the Cocoa framework, and the new features of the iOS 5 SDK. After this, you'll jump straight in and create applications using Xcode and Interface Builder using the new storyboard layout. We then finish up by learning how to make your applications run smoothly using the Xcode instruments.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 244
Veröffentlichungsjahr: 2012
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2012
Production Reference: 1170112
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84719-226-7
www.packtpub.com
Cover Image by Evelyn lam (<[email protected]>)
Author
Steven F. Daniel
Reviewers
Cory Bohon
John Dometita
Richard England
Chris Gummer
Thanh Huynh
Robb Lewis
Dan Lingman
Acquisition Editor
Wilson D'souza
Lead Technical Editor
Shreerang Deshpande
Technical Editor
Lubna Shaikh
Project Coordinator
Alka Nayak
Proofreader
Lydia May Morris
Indexer
Rekha Nair
Graphics
Manu Joseph
Production Coordinator
Alwin Roy
Cover Work
Alwin Roy
Apple's iOS platform, with iPads, iPhones, and iPod touches is the hottest thing in software development right now. An exquisite OS and hardware demands great development tools, and Apple has provided those tools in the form of Xcode. Xcode, just like iOS, is built with ease-of-use in the mind.
Whether you're new to iOS development, or a seasoned pro, this book will guide you through developing in iOS 5 and Xcode 4 with the same ease-of-use that Xcode is known for. It's like this book and iOS 5 development were meant for each other.
Just like Xcode 4, iOS 5 has a lot of new development features, including one of the most-anticipated feature-iCloud. With iCloud, you can store your application's files and settings in the cloud. This book covers these great new features.
With this book, you'll be developing for iOS 5 and using Xcode 4's newest features in no time.
Cory Bohon
Steven F. Daniel is originally from London, England, but lives in Australia.
He is the owner and founder of GenieSoft Studios (http://www.geniesoftstudios.com/), a software development company based in Melbourne, Victoria.
Steven is an experienced software developer with more than 13 years of experience in developing desktop and web-based applications for a number of companies, including insurance, banking and finance, oil and gas, and local and state government.
Steven is always interested in emerging technologies, and is a member of the SQL Server Special Interest Group (SQLSIG) and the Java Community. Steven has been the co-founder and Chief Technology Officer (CTO) of SoftMpire Pvt Ltd, a company that focused primarily on developing business applications for iOS and Android platforms.
He is also the author of Xcode 4 iOS Development Beginner's Guide.
You can check out his blog at http://geniesoftstudios.com/blog/, or follow him on Twitter at http://twitter.com/GenieSoftStudio.
No book is the product of just the author - he just happens to be the one with his name on the cover.
A number of people contributed to the success of this book, and it would take more space than I have to thank each one individually. A special shout, out goes to Steven Wilding, my acquisition editor, who is the reason that this book exists. Thank you, Steven, for believing in me, and for being a wonderful guide throughout this process. I would like to thank Alka Nayak for ensuring that I stayed on track and got my chapters in on time.
I would also like to thank both my development editors: Shreerang Deshpande and Maitreya Bhakal for their brilliant suggestions on how to improve the chapters, and to Lubna Shaikh for the fantastic job she has done, ensuring that we met the timeframes and delivery for this book.
Lastly, to my reviewers, thank you so much for your valued suggestions and improvements, making this book what it is. I am grateful to each and every one of you.
Thank you also to the entire Packt Publishing team for working so diligently to help bring out a high quality product. Finally, a big thank you to the engineers at Apple for creating the iPhone and the iPad, and for providing developers with the tools to create fun and sophisticated applications. You guys rock.
Finally, I'd like to thank all of my friends for their support, understanding, and encouragement during the writing process. It is a privilege to know each one of you.
Cory Bohon is an indie developer, creating iOS and Mac software using many programming languages, including Objective-C, Java, and C/C++. He is also a technology blogger on http://www.maclife.com/, where he writes about Apple news, and Mac and iOS how tos.
Chris Gummer graduated with a Bachelor's of Science majoring in Computing Science and Statistics, in Sydney, Australia. For over a decade, he has developed various software systems across a range of industries. Currently living in London, UK he specializes in iOS application development. He has worked on high profile App Store applications and internal enterprise solutions for iOS devices. At the age of eight, Chris started programming in BASIC, and he still holds the same passion for programming almost thirty years later.
Thanh Huynh started his career as a LAMP developer, with over 10 years experience, and gradually moved into objective-C. Currently working as a freelance iOS developer, he has worked for two of the biggest media companies in the United Kingdom, News International and BSkyB, producing the Times iPad app and Sky Plus.
Robb Lewis is a web developer and student studying web technologies at Portsmouth University. Robb has a great interest in technology, specifically mobile technology, and is an Apple advocate. Robb also writes about software, technology, and the internet at http://therobb.com.
Dan Lingman got his start in programming back in grade 7, when, after seeing a Space Invaders arcade game, he signed up for a night school course in programming the Commodore Pet. This eventually led to a M.Sc. in Computer Science, with his thesis project being a 3D robotics simulator programming in Objective-C on a NeXTStation.
By day, he works for a licensing company, and by night teaches Java development. He also works on iOS development as the technical lead at NoGoToGames.
NoGoToGames is a small company focused on the development of interesting and genre-breaking iOS software. You can see what they are up to at http://www.nogotogames.com/.
I'd like to thank my wife, May, and my daughters, Katrina and Naomi for their patience while I worked on reviewing this book.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.
This book is dedicated to:
My favorite uncle, Benjamin Jacob Daniel, for always making me smile, and for inspiring me to work hard and achieve my dreams. I miss you a lot.
Chan Ban Guan, for the continued patience, encouragement, support, and most of all, for believing in me during the writing of this book.
Mum and Dad, for always believing in me and for your continued love and support.
My sister Linda, thanks for always being there for me when I needed you most. I love you.
My brother Stuart, thanks for everything Bro.
My niece Ava Madison Daniel, thanks for bringing joy to our family. You’re so cute.
This book would not have been possible without your love and understanding.
Lastly, to my dear friends. Thanks again for your continued love, support and understanding during the writing of this book. It really means a lot to me.
I would like to thank you from the bottom of my heart.
Building on the phenomenal success of its predecessor, iOS 5 includes over 200 new user features as well as an updated SDK containing over 1,500 new APIs. iOS 5 looks set to reinforce the iPhone's dominance in the smartphone market.
iOS 5 Essentials will help you learn how to build simple, yet powerful iOS 5 applications, incorporating iCloud Storage, Twitter, Core Image and Newsstand integration.
You will start by learning about what's new in iOS 5. You'll look at the iCloud Storage APIs, Automatic Reference Counting, Twitter, and AirPlay integration, how to use the various Core Image filters using the Cocoa framework, and the new features of the iOS 5 SDK. After this, you'll jump straight in and create applications using Xcode and Interface Builder using the new storyboard layout. We then finish up by learning how to make your applications run smoothly using the Xcode instruments.
In this book, I have tried my best to keep the code simple and easy-to-understand. I have provided step-by-step instructions with loads of screenshots at each step to make it easier to follow. You will soon be mastering the different aspects of iOS 5 programming, as well as mastering the technology and skills needed to create some stunning applications. Feel free to contact me at <[email protected]> for any queries, or just want to say 'hello'. Any suggestions for improving this book will be highly regarded.
Chapter 1, What's New in iOS5, introduces the developer to the Xcode developer set of tools, the new features of iOS 5, as well as an introduction into Newsstand and the MessageUI framework.
Chapter 2, Using iCloud and the Storage APIs, introduces you to the benefits of using iCloud, and how to incorporate iCloud functionality into your applications to store and retrieve files, and its data through the use of the storage APIs. This chapter will also give you some insight into how to go about handling file-version conflicts when multiple copies of the same file are being updated on more than one iOS device.
Chapter 3, Debugging with OpenGL ES, focuses on the differences between vertex shaders and fragment shaders, and their relationship with one another. We will become familiar with the OpenGL ES 2.0 Programmable pipeline, and look into the new debugging features of OpenGL ES that enables us to track down issues specific to OpenGL ES, right within the Xcode IDE. We will learn more about the OpenGL ES frame capture tool and its ability to stop execution of a program, that will enable the developer to grab the current frame contents that are being rendered on the iOS device, so that program issues can be tracked down and corrected, by taking a closer look at the program state information of objects, by scrolling through the debug navigator stack trace with the ability to see all of the textures and shaders that are currently being used by the application.
Chapter 4, Using Storyboards, gains an understanding of what Storyboards are and how we can apply the various transitions between views. We will take a look into how we are able to create and configure scenes and storyboard files, to present these programmatically. We will also look at how to go about building and integrating Twitter capabilities into our application to tweet photos and standard messages.
Chapter 5, Using AirPlay and Core Image, focuses on learning about the AirPlay and Core Image frameworks, and how we go about using and implementing these into our applications. This chapter also explains the different image filter effects, how to adjust the brightness of an image, as well as how to go about producing a water ripple effect. It also covers how to incorporate AirPlay functionality into your application, so that you can have your application displayed out to an external device, such as an Apple TV.
Chapter 6,Xcode Tools - Improvements, focuses on learning about the improvements that have been made to the Xcode development tools. We will take a look at Automatic Reference Counting (ARC), which is the latest addition that has been made to the LLVM compiler, and how this can help improve application performance, by minimizing issues with our applications. It also covers improvements that have been made to Interface Builder, the iOS Location simulator, and the set of debugging tools for OpenGL ES.
Chapter 7, Making your Applications Run Smoothly Using Instruments, focuses on how we can effectively use Instruments within our applications to track down memory leaks and bottlenecks within our applications that could potentially cause our application to crash on the user's iOS device. We will take a look into each of the different types of built-in instruments that come as part of the Instruments application, learn how we can use the System Trace instrument to monitor system calls, and track down performance issues within an application.
This book assumes that you have an Intel-based Macintosh running Snow Leopard (Mac OS X 10.6.2, or later). You can use Leopard, but I would highly recommend upgrading to Snow Leopard or Lion, as there are many new features in Xcode that are available only to these two operating systems.
We will be using Xcode 4.2.1, which is the integrated development environment used for creating applications for iOS development. You can download the latest version of Xcode at the following link: http://developer.apple.com/xcode/.
If you ever wanted to learn about the latest features of iOS 5 and learn how to incorporate Twitter, iCloud and Core Image framework effects functionality into your applications, then this book is for you. You should have a good knowledge of programming experience with Objective-C, and have used Xcode 4. iOS programming experience is not required.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "Launch Xcode from the /Developer/Applications folder."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "When Xcode is launched, you should see the Welcome to Xcode screen."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title through the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
Welcome to the exciting world of iOS 5, the latest release of Apple's mobile operating system, which is packed with some great new features and improvements to the way things are done. The release of the iPhone 4, back in 2010, took the world by storm. Developers around the world have been embracing the new features, such as incorporating AirPlay features within their applications, making use of the retina display to provide crisp and high-definition graphics within their applications and games, as well as the accelerometer and gyroscope.
When Apple hosted their annual World Wide Developer Conference in June 2011, they introduced more than 200 new features, as well as an updated SDK that features over 1,500 new development APIs. This opened up a lot of ideas for many new applications and the way we do things currently, to be done differently. Some of the great new feature highlights are the ability to support the way in which notification messages are handled by using the new Notification Center, messaging has been greatly improved by using the new iMessage messaging application, and finally, the ability to organize and purchase all of your newspaper and magazine subscriptions using the new Newsstand application.
In this chapter, you will gain an insight into some of the fantastic new features and enhancements that have been incorporated into the latest iOS 5 release. We will also look at how to go about downloading and installing the Xcode developer tools and Software Development Kit (SDK).
In this chapter, we will:
We have a exciting journey ahead of us, so let's get started.
Since the release of Apples iOS operating system back in June 2007, they have incorporated many new features and improvements within each release build of its operating system. In iOS 4, we saw this came with over 1,500 new APIs, as well as some high quality enhancements and improvements.
In iOS 5, Apple has introduced over 200 new features and improvements, as well as 1,500 new APIs and updates to its SDK, to include new features relating to Core Image, Twitter integration, and the Newsstand Kit.
Needless to say, the Xcode 4 development environment has also undergone some improvements to allow your applications to be compiled with the new LLVM compiler 3.0 that supports Automatic Reference Counting (ARC). Hence, you rarely need to retain or release your objects, as ARC does most of the work for you. In some cases, you will still need to use retain/release. Storyboard support has also been integrated into Interface Builder, which allows you to design multiple-view workflows for each of your views.
Lastly, debugging OpenGL ES projects are a lot easier, as these have been integrated into the Xcode debugging interface.
In the following sections, we will focus in detail on some of the new features that come with iOS 5.
A neat new feature that comes as part of this release is the Reminders App. A good way to think of reminders would be to think of them as to-do lists. Reminders can prove to be a life-saver, as they give you the flexibility to organize your day-to-day tasks, and come complete with the ability to add due dates and locations.
When you set up your reminders to use locations, you can specify to be reminded on a specific day or location, as well as being reminded either when you arrive or leave the location. They make use of your mobile phone's GPS, similar to how your car's navigation system works, and are designed to alert you as soon as you approach the designated area. Let's take an example, say for instance, you wanted to buy a new printer and some additional ink, you set up your reminder to automatically send you an alert as soon as you pulled into your local stores, parking lot.
Finally, another thing to mention about reminders: since these have been integrated into iOS 5, they have been designed to work well with other applications. For example, Apple iCal, Microsoft Outlook, and iCloud. This has been done to ensure that any changes you make will automatically update on all of your devices and calendars.
The following screenshots shows a list of items that have been added to a to-do list, and then shows how you can configure and specify when to be reminded. You can choose to be reminded when you leave or arrive at a particular location. The final screenshot shows the reminder pop-up when the specified time has been reached. Additional items can be added to the list by selecting the + plus sign, as highlighted by a rectangle.
Notifications play an important role in an iPhone user's everyday life. Notifications come in the form of pop-ups to inform you that a new e-mail has arrived, of new SMS text messages, of friend requests from social networking sites, notifications when your phone credit falls below a certain amount, and much more. With the Notification Center application, you don't need to worry about locating that e-mail, SMS text message, or friend request. It has been made simple enough for you to keep track of all of these forms of notifications in one convenient location.
The Notification Center can be accessed by simply placing your finger anywhere at the top of the screen and swiping in a downward motion. There are many different notifications to choose from when you are in this view. For instance, you can choose to see the current weather forecast, your stock shares, calendar entries of upcoming appointments, and so on. As new notifications come through, they will be added and will appear at the top of the list for easier access, without interrupting what you're doing.
You can also act upon Notifications through the lock screen on your iOS device; these appear categorized within a table view, so that you can act on them quickly by simply sliding the panel to unlock and take you to the relevant application. For example, if you receive a message, this will open up the iMessage application. As you can see, the Notification Center provides you with a much better way of staying on top of your life's activities.
The Newsstand is a central place, where iOS users can access their subscribed magazines and newspapers. Unlike iBooks, where book publishers supply .epub files or similar documents, Newsstand publishers will have to create an iOS application (or adapt their existing application). Think of it like a cross between the shelf seen in the iBooks application and applications folders on the home screen.
To make use of the new features, publishers must invoke the newly added Newsstand Kit framework. There are some simple settings that need to be configured to allow your application to recognize that it is a magazine or a newspaper, so that it can be placed within the Newsstand application, instead of running as a standalone application.
In the coming section, we will proceed to download and install the iOS 5 SDK. If you have already installed this, you can skip this section altogether and proceed to the next section.