Home > Store

Sams Teach Yourself Cocoa Touch Programming in 24 Hours, Portable Documents

Register your product to gain access to bonus material or receive a coupon.

Sams Teach Yourself Cocoa Touch Programming in 24 Hours, Portable Documents

eBook (Watermarked)

  • Sorry, this book is no longer in print.
  • About Watermarked eBooks
  • This PDF will be accessible from your Account page after purchase and requires PDF reading software, such as Acrobat® Reader®.

    The eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

    Watermarked eBook FAQ

Not for Sale

Description

  • Copyright 2010
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-7686-9552-X
  • ISBN-13: 978-0-7686-9552-6

In Full Color

Code samples are syntax highlighted as in Xcode!!

In just 24 sessions of one hour or less, learn how to build powerful mobile applications with Apple’s Cocoa Touch technology for the iPhone and iPod touch! Using this book’s straightforward, step-by-step approach, you’ll master every skill and technology you need, from handling user interaction and building effective user interfaces to accessing the Internet, playing media, and using the iPhone and iPod touch’s incredible sensing capabilities. Each lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!

Step-by-step instructions carefully walk you through the most common Cocoa Touch programming tasks.

Quizzes and Exercises at the end of each chapter help you test your knowledge.

By the Way notes present interesting information related to the discussion.

Did You Know? tips offer advice or show you easier ways to perform tasks.

Watch Out! cautions alert you to possible problems and give you advice on how to avoid them.

  • Write simple, efficient code that reflects a clear understanding of how Cocoa Touch works and why it works that way
  • Build great iPhone/iPod touch user interfaces from the ground up
  • Display tables and provide for clear navigation
  • Access the Internet and networks and show web pages
  • Save and retrieve data, including user preferences
  • Understand how the Cocoa Touch runtime loop interacts with your application
  • Draw and manipulate images
  • Create complex animations such as Cover Flow
  • Build applications that play and record media
  • Use the iPhone’s built-in accelerometer, GPS capabilities, and WiFi support
  • Share data via custom URLs, emails, and other techniques
  • Find and fix common Cocoa Touch software bugs, fast
  • Avoid the performance bottlenecks that affect Cocoa Touch code

Sample Content

Table of Contents

Introduction     1

About This Book     1

About You     2

About Objective-C     2

What You Need     2

How to Read This Book     3

Conventions Used in This Book     3

PART I: Understanding the Objective-C Language

HOUR 1: Starting Your First Application: A Calculator     5

Setting Up Your Development Tools     5

Using Xcode     6

Using Interface Builder     13

Summary     20

Workshop     21

Exercise      21

HOUR 2: Handling Interaction     23

Objective-C     23

Binding an Object to the User Interface     31

Basic Memory Management     39

Invoking Methods on nil     41

Type Checking Rules     41

Type Equivalence     42

Type Checking     42

Summary     44

Q&A     45

Workshop     45

Exercise     46

HOUR 3: Simplifying Your Code     47

Managing Memory with NSAutoReleasePools     47

Objective-C Strings     52

Introducing the Debugger      62

Understanding Messaging      65

Debugging a Real Bug     68

Using Shorthands     70

Summary     74

Q&A     74

Workshop     74

Exercises     75

HOUR 4: Making the Calculator Calculate     77

A Simple Calculator     78

Mutable Classes: Making a “Printing” Calculator     82

Dynamic Objective-C     88

Summary     96

Q&A     96

Workshop     96

Exercises     97

HOUR 5: Adding Variables to the Calculator     99

A Better Model/Controller Split      99

Using an NSDictionary to Add Variables to the Calculator     106

The Key-Value Coding and Observing Protocols     113

Summary     120

Workshop     120

Exercise     121

PART II: User-Interface Foundations

HOUR 6: Understanding How the User Interface Is Built     123

User-Interface Building-Blocks: Views     123

Building the UI from Views     136

Summary     147

Q&A     147

Workshop      148

Exercise     148

HOUR 7: Understanding How Events Are Processed     149

Run Loops and Core Foundation     149

How Cocoa Uses the Run Loop     155

Touch Event Dispatching     160

Summary     167

Q&A     168

Workshop     168

Exercises     169

HOUR 8: Drawing User-Interface Elements      171

Adding Images to UIButton     171

Core Graphics     178

Drawing Your Own Button     194

Summary     199

Q&A     199

Workshop     199

Exercises     200

HOUR 9: Layers and Core Animation: Creating a Cover Flow Clone     201

Placing Layers in 3D Space     202

Using Core Animation     208

Creating a Cover Flow Clone     220

Summary     230

Q&A     230

Workshop     231

Exercises     231

PART III: Advanced User-Interface Elements

HOUR 10: Using View Controllers     233

View Controllers     233

Adding a Scientific Mode to the Calculator     242

Summary     250

Q&A     250

Workshop     251

Exercises     252

HOUR 11: Displaying Tables     253

Creating Tables      254

Using Table Cells     261

Creating a Twitter Application     268

Summary     272

Q&A     273

Workshop     273

Exercises     274

HOUR 12: Adding Navigation and Tab Bar Controllers     275

Using Modal View Controllers     275

Saving Application Defaults     279

Using Tab Bars     283

Using Navigation Bars     287

Summary     295

Q&A     295

Workshop     295

Exercises     296

HOUR 13: Adding Undo and Redo Functionality     297

Creating Your Own Undo/Redo Manager     297

Using NSUndoManager     305

Summary     307

Q&A     307

Workshop     308

Exercise      308

PART IV: Accessing the Internet

HOUR 14: Accessing the Network      309

How Networks Work     309

How the Web Works     316

Using Cocoa Touch to Access the Web     321

Making the Twitter Application Deal with Errors     328

Summary     330

Q&A     331

Workshop     331

Exercises     332

HOUR 15: Showing a Web Page     335

Understanding UIWebView     335

Using UIWebViews     339

Using WebKit Extensions     345

Summary     352

Q&A     352

Workshop     353

Exercises     354

PART V: Saving and Retrieving Data

HOUR 16: Adding Application Preferences     355

Retrieving Settings Set by the Settings Application     356

Creating a Settings Bundle for the Settings Application     357

Dynamically Updating Data from the Network     365

Summary     368

Q&A     369

Workshop     369

Exercises     370

HOUR 17: Using the SQLite Database     371

Saving and Reading Data from Files     371

Saving and Reading Data from an SQLite Database     373

Summary     385

Q&A     385

Workshop     385

Exercise     386

HOUR 18: Using Core Data     387

Using NSSortDescriptor and NSPredicate     387

Using Core Data     390

Using Xcode to Design Objects     404

Summary     407

Q&A     407

Workshop     407

Exercises     408

PART VI: Interacting with the World

HOUR 19: Playing and Recording Media     409

Playing and Recording Audio     409

Playing Video Files     426

Summary     429

Q&A     430

Workshop     430

Exercises     431

HOUR 20: Sensing the World     433

Using the iPhone’s Accelerometer     433

Determining the iPhone’s Location     438

Taking Photos and Making Short Videos     444

Summary     446

Q&A     446

Workshop     446

Exercises     447

HOUR 21: Sharing Data     449

Using Custom URLs     449

Using Pasteboards     452

Exporting Data     455

Summary     459

Q&A     459

Workshop     460

Exercises     461

PART VII: Completing Your Application

HOUR 22: Debugging     463

Using gdb, dtrace, valgrind, and nib2objc     463

Resolving Cocoa Misunderstandings     472

Summary     477

Q&A     477

Workshop     477

Exercise     478

HOUR 23: Optimizing Performance     79

Profiling Your Code     . 479

Optimizing Your Memory Usage     486

Optimizing Your Code’s Speed     495

Summary     500

Q&A     500

Workshop     501

Exercise     502

HOUR 24: Shipping Your Application     503

Polishing Your Application for Submission     503

Localizing Your Application     506

Submitting Your Application to the App Store     514

Summary     517

Q&A     518

Workshop     519

Exercise     520

APPENDIX A: C Primer (Online)      521

Functions     521

Primitive Types     521

Basic Operators     522

Function Signatures     522

Interface Files     522

System Libraries     522

Composite Structures     523

Memory Access     523

Arrays     524

Dynamic Memory Allocation     524

Strings     524

Types     525

New Kinds of Errors     525

APPENDIX B: Troubleshooting Xcode (Online)      527

Logging in to the Developer Website     527

Obtaining Permission to Upload Your Application to Your Device     529

Building Your Application to Run on a Device     531

Updating Mobile Provisions      533

Debugging the Ambiguous Matches Error     534

Uploading Your Application to Your Device     534

Checking Changes That Do Not Show Up     540

Checking the App Store Executable     541

APPENDIX C: Resources     543

This Book’s Website     543

Books and Papers     543

Web Resources     545

APPENDIX D: Advanced Topics (Online)      547

Testing String Mutability with Exceptions     547

Uncaught Exceptions     547

The Implementation of Exceptions.      548

NSZones     549

Creating Singletons by Overriding allocWithZone:      550

Extending Objects by Overriding allocWithZone:      551

How Applications Start     552

Threads     553

pthreads     554

NSThreads     555

Deciding Whether to Use Threading or One-Shot Invocation     560

Types of Layers     562

View Controller Hierarchy Used in the Twitter Application     566

Index     567

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020