Programming iOS 5, Second Editionby Matt Neuburg Copyright © 2012 Matt Neuburg.. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.. Nutshell Handbo
Trang 3SECOND EDITION
Programming iOS 5
Matt Neuburg
Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo
Trang 4Programming iOS 5, Second Edition
by Matt Neuburg
Copyright © 2012 Matt Neuburg 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 corporate@oreilly.com.
March 2012: Second Edition
Revision History for the Second Edition:
2011-12-23 Early release
2012-03-12 First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449319342 for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc Programming iOS 5, the image of a kingbird, 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 trademark 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 con-tained herein.
ISBN: 978-1-449-31934-2
[M]
1331571373
Trang 5Table of Contents
Preface xvii Part I Language
1 Just Enough C 3
2 Object-Based Programming 31
3 Objective-C Objects and Messages 43
iii
Trang 6About the Author
Matt Neuburg has a PhD in Classics and has taught at many universities and colleges
He has been programming computers since 1968 He has written applications for Mac
OS X and iOS, is a former editor of MacTech Magazine, and is a long-standing
contri-buting editor for TidBITS His previous O'Reilly books are Frontier: The Definitive
Guide, REALbasic: The Definitive Guide, and AppleScript: The Definitive Guide He
makes a living writing books, articles, and software documentation, as well as by pro-gramming, consulting, and training
Colophon
The animal on the cover of Programming iOS 5 is a kingbird, one of the 13 species of North American songbirds making up the genus Tyrannus A group of kingbirds is
called a “coronation,” a “court,” or a “tyranny.”
Kingbirds eat insects, which they often catch in flight, swooping from a perch to grab the insect midair They may also supplement their diets with berries and fruits They have long, pointed wings, and males perform elaborate aerial courtship displays Both the genus name (meaning “tyrant” or “despot”) and the common name (“king-bird”) refer to these birds’ aggressive defense of their territories, breeding areas, and mates They have been documented attacking red-tailed hawks (which are more than twenty times their size), knocking bluejays out of trees, and driving away crows and ravens (For its habit of standing up to much larger birds, the gray kingbird has been adopted as a Puerto Rican nationalist symbol.)
“Kingbird” most often refers to the Eastern kingbird (T tyrannus), an average-size
kingbird (7.5–9 inches long, wingspan 13–15 inches) found all across North America This common and widespread bird has a dark head and back, with a white throat, chest, and belly Its red crown patch is rarely seen Its high-pitched, buzzing, stuttering sounds have been described as resembling “sparks jumping between wires” or an elec-tric fence
The cover image is from Cassell’s Natural History The cover font is Adobe ITC
Gara-mond The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont’s TheSansMonoCondensed
Trang 7D