Learning iOS Programming From Xcode To App Store Third Edition Alasdair Allan - The Ebook in PDF Format Is Ready For Download
Learning iOS Programming From Xcode To App Store Third Edition Alasdair Allan - The Ebook in PDF Format Is Ready For Download
com
https://ebookname.com/product/learning-ios-programming-from-
xcode-to-app-store-third-edition-alasdair-allan/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookname.com/product/learning-iphone-programming-from-
xcode-to-app-store-1st-edition-alasdair-allan/
https://ebookname.com/product/learning-cocoa-with-objective-c-
developing-for-the-mac-and-ios-app-stores-third-edition-paris-
buttfield-addison/
https://ebookname.com/product/ios-8-programming-fundamentals-
with-swift-swift-xcode-and-cocoa-basics-1st-edition-matt-neuburg/
https://ebookname.com/product/j-k-lasser-s-new-tax-law-
simplified-2011-tax-relief-from-the-american-recovery-and-
reinvestment-act-and-more-1st-edition-barbara-weltman/
European Products Making and Unmaking Heritage in
Cyprus 1st Edition Gisela Welz
https://ebookname.com/product/european-products-making-and-
unmaking-heritage-in-cyprus-1st-edition-gisela-welz/
https://ebookname.com/product/small-animal-dermatology-a-color-
atlas-and-therapeutic-guide-second-edition-linda-medleau/
https://ebookname.com/product/experiences-of-depression-
theoretical-clinical-and-research-perspectives-1st-edition-
sidney-j-blatt/
https://ebookname.com/product/city-logistics-mapping-the-
future-1st-edition-eiichi-taniguchi/
https://ebookname.com/product/languages-of-intentionality-a-
dialogue-between-two-traditions-on-consciousness-1st-edition-
paul-s-macdonald/
Athenaze An Introduction to Ancient Greek Book I 2nd
Edition Maurice Balme
https://ebookname.com/product/athenaze-an-introduction-to-
ancient-greek-book-i-2nd-edition-maurice-balme/
THIRD EDITION
Alasdair Allan
Learning iOS Programming, Third Edition
by Alasdair Allan
Copyright © 2013 Alasdair Allan. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or [email protected].
Editor: Rachel Roumeliotis Cover Designer: Randy Comer
Production Editor: Kristen Borg Interior Designer: David Futato
Proofreader: Rachel Leach Illustrator: Rebecca Demarest
Indexers: Fred Brown and Meghan Jones
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. Learning iOS Programming, the image of a lapwing, and related trade dress are trademarks of
O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐
mark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-35934-8
[LSI]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
1. Why Go Native?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
The Pros and Cons 1
Why Write Native Applications? 2
The Release Cycle 4
Build It and They Will Come 5
2. Becoming a Developer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Registering as an iOS Developer 7
Enrolling in the iOS Developer Program 10
The Mac Developer Program 11
Installing the iOS SDK 11
What Happens When There Is a Beta? 16
Preparing Your iOS Device 16
Creating a Development Certificate 17
Getting the UDID of Your Development Device 20
Creating an App ID 20
Creating a Mobile Provisioning Profile 21
Making Your Device Available for Development 22
iii
Building the User Interface 44
Connecting the User Interface to the Code 45
Running the Application in the Simulator 49
Putting the Application on Your iPhone 51
4. Coding in Objective-C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Declaring and Defining Classes 53
Declaring a Class with the Interface 53
Defining a Class with the Implementation 55
Object Typing 55
Properties 56
Synthesizing Properties 57
The Dot Syntax 58
Declaring Methods 58
Calling Methods 59
Calling Methods on nil 60
Memory Management 60
Creating Objects 61
The Autorelease Pool 61
The alloc, retain, copy, and release Cycle 62
Automatic Reference Counting 63
The dealloc Method 64
Responding to Memory Warnings 64
Fundamental iOS Design Patterns 64
The Model-View-Controller Pattern 65
Views and View Controllers 66
The Delegates and DataSource Pattern 67
Conclusion 67
iv | Table of Contents
Deleting a City Entry 107
Adding a City Entry 108
The “Add New City” Interface 111
Capturing the City Data 119
Table of Contents | v
Retrieving Twitter Trends 248
Using the Social Framework 250
The Twitter Trends Application 251
Regular Expressions 260
Introduction to Regular Expressions 260
Storing Data 265
Using Flat Files 265
Storing Information in a SQL Database 266
Core Data 274
vi | Table of Contents
Annotating Maps 325
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
The arrival of the iPhone changed everything. Or, at the very least, it changed the di‐
rection of software development for mobile platforms, which is a pretty big thing. It has
spawned an entire generation of copycat devices and brought an entire multibillion-
dollar industry to its knees. Despite this, it still fits in your pocket.
Third Edition
There have been a lot fewer changes between the release of iOS 5 and iOS 6 than between
the release of iOS 3 and iOS 5, especially since changes to Xcode 4 have now slowed as
it has matured. Consequently the changes here in the third edition are less sweeping
than they were in the second. Nonetheless, the book you now hold in your hands has
been updated to reflect the changes Apple has made to Xcode to support the arrival of
the iPhone 5 and iOS 6, as well as discussing the changes in iOS 6 that seemed interesting
or relevant to mention as part of a introductory title.
ix
for the first time, drawn to the platform because of the iPhone, or alternatively are an
experienced Mac programmer making the transition to the iOS, this book is for you.
x | Preface
applications, these classes can be used to solve a large cross section of problems,
and as a result, they appear almost everywhere. In this chapter, we dive fairly deeply
into the table view classes.
Chapter 6, Other View Controllers
After discussing the table view controller in detail, we discuss some of the other
view controllers and classes that will become useful when building your applica‐
tions: simple two-screen views, single-screen tabbed views, modal view controllers,
and a view controller for selecting video and images.
Chapter 7, Connecting to the Network
This chapter discusses connecting to the Internet, browsing the Web, sending email,
and retrieving information.
Chapter 8, Handling Data
This chapter discusses how to handle data input, both from the application user
and programmatically, and how to parse XML and JSON documents. The chapter
also covers storing data in flat files and storing data with the SQLite database engine.
Chapter 9, Using Sensors
This chapter discusses how to determine what hardware is available and illustrates
how to deal with the major sensors on iOS devices: the accelerometer, magneto‐
meter, camera, and GPS.
Chapter 10, Geolocation and Mapping
This chapter walks you through the process of building applications that make use
of the Core Location and MapKit frameworks.
Chapter 11, Introduction to iCloud
This chapter provides a brief introduction to integrating Apple’s iCloud service into
your own applications. iCloud is a service that helps you synchronize your data
across devices, making documents and data available to all of your subscribed
devices.
Chapter 12, Integrating Your Application
This chapter shows you some of the tricks to integrate your application with iOS’s
software ecosystem, how to present user preferences with Settings Bundles, and
how to use custom URL schemes to launch your application. It also discusses how
to make use of the Media Player and Address Book.
Chapter 13, Distributing Your Application
This chapter talks about how to add some final polish to your application and walks
you through the process of building your application for distribution, either via ad
hoc distribution or for the App Store.
Preface | xi
Chapter 14, Going Further
This chapter provides a collection of pointers to more advanced material on the
topics we covered in the book, as well as material covering some of those topics that
we didn’t manage to talk about in the book.
xii | Preface
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “Learning iOS Programming (3rd ed) by
Alasdair Allan. Copyright 2013 Alasdair Allan, 978-1-44935-934-8 (O’Reilly).”
If you feel your use of code examples falls outside fair use or the permission given here,
feel free to contact us at [email protected].
How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://oreil.ly/learn-ios-programming-3e. Sup‐
plementary materials are also available at http://www.learningiosprogramming.com/.
To comment or ask technical questions about this book, send email to bookques
[email protected].
For more information about our books, conferences, Resource Centers, and the O’Reilly
Network, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Safari Books Online offers a range of product mixes and pricing programs for organi‐
zations, government agencies, and individuals. Subscribers have access to thousands of
books, training videos, and prepublication manuscripts in one fully searchable database
Preface | xiii
Another Random Document on
Scribd Without Any Related Topics
Denkens selber drin steht, vermag wohl sein Wesen, nicht aber seine
Erscheinung zu erfassen. Die Beurteilung nach der blossen
Erscheinung kann dem Wesen nicht gerecht werden, daher sie meist
entwertend ausfällt. Dem Wesen nach aber ist dieses Denken nicht
minder fruchtbar und schöpferisch als das introvertierte Denken, nur
dient sein Können andern Zielen als dieses. Dieser Unterschied wird
dann besonders fühlbar, wenn das extravertierte Denken sich eines
Stoffes, der ein spezifischer Gegenstand des subjektiv orientierten
Denkens ist, bemächtigt. Dieser Fall tritt ein, wenn z. B. eine
subjektive Überzeugung analytisch aus objektiven Tatsachen oder als
Folge und Ableitung aus objektiven Ideen erklärt wird. Noch
offenkundiger für unser naturwissenschaftlich orientiertes
Bewusstsein aber wird der Unterschied der beiden Denkarten, wenn
das subjektiv orientierte Denken den Versuch macht, objektiv
Gegebenes in objektiv nicht gegebene Zusammenhänge zu bringen,
d. h. einer subjektiven Idee zu unterstellen. Beides wird als Übergriff
empfunden und dabei tritt dann jene Schattenwirkung hervor,
welche die beiden Denkarten aufeinander haben. Das subjektiv
orientierte Denken erscheint dann als reine Willkür, das
extravertierte Denken dagegen als platte und banale
Incommensurabilität. Deshalb befehden sich die beiden Standpunkte
unaufhörlich. Man könnte meinen, dieser Streit wäre dadurch leicht
zu beendigen, dass man die Gegenstände subjektiver von
denjenigen objektiver Natur reinlich schiede. Diese Scheidung ist
leider ein Ding der Unmöglichkeit, obschon nicht wenige sie
durchzuführen versucht haben. Und wenn diese Scheidung auch
möglich wäre, so wäre sie ein grosses Unheil, indem beide
Orientierungen an sich einseitig und nur von beschränkter Gültigkeit
sind, und darum eben ihrer gegenseitigen Beeinflussung bedürfen.
Wenn das objektiv Gegebene das Denken in irgendwie höherm
Masse unter seinen Einfluss bringt, so sterilisiert es das Denken,
indem letzteres zu einem blossen Anhängsel des objektiv Gegebenen
erniedrigt wird, sodass es in keinerlei Hinsicht mehr imstande ist,
sich vom objektiv Gegebenen bis zur Herstellung eines abgezogenen
Begriffes zu befreien. Der Prozess des Denkens beschränkt sich dann
auf ein blosses „Nachdenken“, nicht etwa im Sinne von
„Überlegung“, sondern im Sinne von blosser Imitation, die im
wesentlichen durchaus nichts anderes besagt, als was im objektiv
Gegebenen allbereits ersichtlich und unmittelbar vorlag. Ein solcher
Denkprozess führt natürlich zum objektiv Gegebenen unmittelbar
zurück, aber niemals darüber hinaus, also nicht einmal zum
Anschluss der Erfahrung an eine objektive Idee; und umgekehrt,
wenn dieses Denken eine objektive Idee zum Gegenstand hat, so
wird es nicht imstande sein, die praktische Einzelerfahrung zu
erreichen, sondern es wird in einem mehr oder weniger
tautologischen Zustand verharren. Hiefür liefert die materialistische
Mentalität einleuchtende Beispiele.
Wenn das extravertierte Denken infolge einer verstärkten
Determination durch das Objekt dem objektiv Gegebenen unterliegt,
so verliert es sich einerseits gänzlich in der Einzelerfahrung und
erzeugt eine Anhäufung unverdauter empirischer Materialien. Die
bedrückende Masse mehr oder weniger zusammenhangsloser
Einzelerfahrungen schafft einen Zustand gedanklicher Dissociation,
der in der Regel auf der andern Seite eine psychologische
Compensation erfordert. Diese besteht in einer ebenso einfachen wie
allgemeinen Idee, welche dem aufgehäuften, aber innerlich
unverbundenen Ganzen einen Zusammenhang geben, oder
wenigstens die Ahnung eines solchen vermitteln soll. Passende Ideen
zu diesem Zweck sind etwa „Materie“ oder „Energie“. Hängt aber das
Denken nicht in erster Linie zu viel an äussern Tatsachen, sondern
an einer überkommenen Idee, so entsteht aus Compensation der
Armut dieses Gedankens eine umso eindrucksvollere Anhäufung von
Tatsachen, die eben einseitig nach einem relativ beschränkten und
sterilen Gesichtspunkt gruppiert sind, wobei regelmässig viel
wertvollere und sinnreichere Aspekte der Dinge gänzlich verloren
gehen. Die schwindelerregende Fülle der sogenannten
wissenschaftlichen Literatur unserer Tage verdankt, zu einem leider
hohen Prozentsatz, ihre Existenz dieser Misorientierung.
2. Der extravertierte Denktypus.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com