iOS 4 Programming Cookbook
Solutions & Examples for iPhone, iPad, and iPod touch Apps
Publisher: O'Reilly Media
Final Release Date: January 2011
Pages: 640

You can build a variety of amazing apps on the iOS platform—and every one of them presents a unique set of problems. With the recipes in this cookbook, you'll go beyond theory to solve the vexing, real-life issues you’re likely to face when creating apps for the iPhone, iPad, or iPod Touch. Each recipe provides a clear solution and sample code that you can use right away.

You'll find solutions for working with development frameworks in iOS SDK 4 and technologies such as Cocoa, Objective-C, Xcode, and Interface Builder. Whether you have a little or a lot of experience with iOS development, you’ll find the help you need for every phase of the process, from initial idea to completed project.

  • Work with Objective-C classes, objects, properties, delegates, and memory management
  • Construct a user interface with gesture recognizers
  • Develop location-aware applications with the Map Kit and Core Location APIs
  • Build apps that play audio and video, manage calendars and events, access contacts and groups, or tap into the Photo Library
  • Use the Core Motion framework to access the accelerometer and gyroscope
  • Maintain persistent storage for iOS apps with the Core Data framework
  • Create multitasking-aware apps that let users leave and return without losing their place
Table of Contents
Product Details
About the Author
Colophon
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
O'Reilly MediaiOS 4 Programming Cookbook
 
4.0

(based on 10 reviews)

Ratings Distribution

  • 5 Stars

     

    (2)

  • 4 Stars

     

    (7)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (1)

  • 1 Stars

     

    (0)

80%

of respondents would recommend this to a friend.

Pros

  • Helpful examples (8)
  • Accurate (4)
  • Easy to understand (3)

Cons

    Best Uses

    • Intermediate (8)
    • Expert (4)
      • Reviewer Profile:
      • Developer (8)

    Reviewed by 10 customers

    Sort by

    Displaying reviews 1-10

    Back to top

    (5 of 6 customers found this review helpful)

     
    4.0

    Good, but not your only (or first) book

    By Graham Weir

    from London, UK

    About Me Developer

    Verified Reviewer

    Pros

    • Advanced
    • Helpful examples

    Cons

    • Not comprehensive enough
    • Too basic

    Best Uses

    • Intermediate

    Comments about O'Reilly Media iOS 4 Programming Cookbook:

    Disclaimer: The author is a coworker of mine at Monitise Group, and I got a sample copy of the book in return for writing a review.

    First things first: it's a good book. It's covers a lot of area, and it has a *lot* of usable sample code; there's an excellent chance that you can see things and immediately apply them to your own projects. It also covers the stuff which is a pain to find good information about online, such as the C frameworks (EventKit, AddressBook, etc). I know from experience that Apple's sample code for this tends to be unhelpful, and I spotted at least two flat out wrong things in Apple's AddressBook documentation last year, so having a good book for the C frameworks is nice. It also covers much of the iOS 4.0 stuff, such as multitasking. (Older books tend to either not cover it because iOS 4.0 only came out in June 2010, or they rushed it because they desperately needed to have something on the page about it. This book gives it a decent treatment.)

    What's not so good is that the book tries to walk a tightrope between being a beginner book and an advanced book, and ends up in the middle somewhere. There's a lot of overview material, such as refreshers on the basics of retain/release memory management, that advanced iOS programmers will already know, but which have large gaps that less experienced programmers will fall into without even realizing it. For example (and only people who know some Objective-C will understand what I mean here), that overview of retain/release memory management gives a *paragraph* to autorelease, which mostly suggests using manual release instead. I can understand that argument and its advantages, even if I don't agree with it. However, the great majority of objects you deal with in an Objective-C app - including almost every NSString you make - were already autoreleased by Apple's code! If you don't know at least the basics of autorelease, I don't think you can write a program without mysterious crashes all over the place...and this book expects you to already know about it. If this is an advanced book, why was any space spent on the basics? If it's a near-beginners book, why do the overviews not teach you *everything* you need to know?

    Bear in mind that this is a good book, even though I spent more time talking about the negatives than the positives; it's just that it cannot be your only Objective-C book. You *need* some experience in writing apps for iOS or the Mac before you can use it. I wish they'd taken out the basics, but them in some other book, and crammed in some more advanced-level material...but then, these days, if a book covered every 'advanced' thing in iOS in enough detail to make me happy, I'd have to take it off the shelf with a forklift.

    (4 of 5 customers found this review helpful)

     
    4.0

    Very handy book for iOS developers

    By Linyu

    from London

    Verified Reviewer

    Comments about O'Reilly Media iOS 4 Programming Cookbook:

    This is a quite handy book for iOS developers. It is not for beginners though; a basic understanding of Obj-C and iOS programming is needed.

    The good thing about this book is that it gives you a complete solution to a specific problem you might come up. I normally do a Google search for a code snippet, but most of the results are not verified or confirmed. Sometimes I just end up spending lots of time wondering around for a simple function. This book provided samples and discussions in different categories, which makes it easy to navigate and locate the problem you want to solve.
    The explanation of each receipt is very clear as well.

    When I wanted to use Core Data in one of my apps, I just did a search in Apple's documents, and got a really long list. There is a tutorial, but not much on actually add it into my app. I then turned to this book for help; there is a complete section about Core Data, including every operation I need to implement, separated into receipt. So I can just follow the receipt to add Core Data support. That's the thing I need!

    Some of the receipts there are from iOS3.x though, not updated to iOS4. Taking movie playing for example, Apple has provided a new simpler controller to play full screen movie since iOS3.2. But the receipt in this book failed to mention it.

    Generally speaking, it is very useful and practical. I would suggest every iOS developer to put this book on the desk as a reference.

    (2 of 3 customers found this review helpful)

     
    4.0

    iOS code examples and APIs

    By Rob

    from Brisbane, Australia

    About Me Developer

    Pros

    • Accurate
    • Helpful examples

    Cons

      Best Uses

      • Intermediate
      • Novice

      Comments about O'Reilly Media iOS 4 Programming Cookbook:

      The iOS 4 Programming Cookbook is an interesting book. When reading it my emotions ranged excited, happy, pleasantly surprised to puzzled. One of the things I often try and do when reviewing technical books is to try and understand who the target audience is, put myself in their place, and do what they would do. With iOS 4 Programming Cookbook style seemed to vary greatly in who it was targeting. The beginning covered many very basic topics, while later stages required more understanding. Overall it seemed to be aiming at someone without extensive programming experience, and was focused on making it possible for most people to follow the recipes.

      I've not read that many programming cookbooks in the past, preferring to aim at getting a deeper understanding of topics than finding the "repeatable recipes" covered in programming cookbooks. That said, the cookbook format seems useful in an iOS and ObjectiveC environment, where there are many areas that require the kind of boilerplate code that can be found in cookbooks.

      One of the best uses that I found for the iOS 4 Programming Cookbook, has been to quickly identify device features for iOS that can easily be used, and the APIs for working with them. I've used it a couple of times when thinking through device options, and how to leverage the functionality of iOS.

      Overall I'd recommend the book to someone who is looking at building something for the iOS that utilises the hardware and software provided by Apple.

      [this book was reviewed as a part of the O'Reilly Blogger Review Program]

      (4 of 5 customers found this review helpful)

       
      4.0

      Good for the post-novice

      By Derek S

      from Fresno, CA

      Verified Reviewer

      Comments about O'Reilly Media iOS 4 Programming Cookbook:

      iOS4 Programming Cookbook is geared towards the iOS programmer who has passed the novice stage, but isn't necessarily an expert. You should know the basics of building an iPhone app including:

      Objective C
      Linking code with Interface Builder (IBOutlet, IBAction)
      UIView general usage
      My perspective is having gone through many samples from books and now I have an idea of what I want to create: a tab bar application that uses some Quart 2D graphics to display a pie chart and a simple bar chart.

      The Table of Contents is well laid out, which is important for a "cookbook" type of programming guide. I immediately jumped to Chapter 14 "Graphics."

      Each chapter starts with a simple introduction and then builds up the subject with some cases. What it doesn't do is walk you through the steps to creating an app and the reader shouldn't expect that.

      This is the kind of book you keep in your arsenal of tools and it lends itself to an ebook format where you will jump to sections as needed.

      (5 of 6 customers found this review helpful)

       
      4.0

      Highly informative

      By Willis R.

      from Great Britain

      About Me Developer, Programming enthusiast

      Verified Reviewer

      Pros

      • Easy to understand
      • Helpful examples
      • Ios 4 subjects
      • Well-written

      Cons

      • Screenshots can be small

      Best Uses

      • Expert
      • Intermediate
      • Student

      Comments about O'Reilly Media iOS 4 Programming Cookbook:

      Pros:

      - Covers iOS 4 Subjects
      - A lot of useful examples, as another reviewer pointed out
      - Text is simple to understand and not mangled with difficult words
      - Tips and tricks are included in the book
      - Sample codes are tested on ipad, iphone 4 and iphone 3gs

      Cons:

      - Some small screenshots in a few places. My eyes are not that perfect to see the small images!
      - Gyroscope example lacks practical explanation. It doesn't say where we should actually use a gyroscope. A bit disappointing there.
      - Might sometimes be hardcore and hence confusing.

      This book really isn't for novice programmers. It literally says it in the book itself. I have a few apps in the app store and therefore, was able to digest majority of the material covered. But if you are a true beginner, you better look elsewhere. If you are a true beginner, you probably want to learn objective-c, not cocoa touch. Just search for "cocoa touch book" in google to see what books are best for that.

      Operations and threads chapter is the best part of this book + multitasking and audio and video. The issue that I have is I don't actually have an iphone but I've developed some apps that make use of audio and video capabilities of iOS devices. If you open the Audio and Video chapter, you will see that the examples the author has tried are actually on an iphone 4 and some iPhone 3gs if I am not mistaken and because of this he has been able to deal with things such as "handling incoming phone call when you are playing an audio". This is the type of stuff I was looking for in a book and I found them here. I cannot afford an iphone for now but this book I could afford.

      Core location and maps was also another interesting chapter. The good thing is when you mix this chapter with the Multitasking chapter. Then you get a good idea how you can for instance, detect the user's location even if your app is in the background. I can think of hundreds of app ideas that simply make use of the location apis and background processing. For example, detecting which bus stop is closes to the user and popping an alert on the screen saying "Hey, there is a bus stop 1/2 mile away from you". So I suggest that you definitely read the Multitasking chapter.

      I liked the book. I think some improvements are necessary such as increasing the number of example codes in the gyroscope and accelerometer chapter. Other than that, I liked the book.

      (5 of 6 customers found this review helpful)

       
      5.0

      The real deal

      By Allan Lancing

      from London, UK

      About Me Developer

      Verified Reviewer

      Pros

      • Accurate
      • Concise
      • Easy to understand
      • Helpful examples
      • IOS 4 subjects covered
      • Lots of examples
      • Lots of topics covered
      • Well-written

      Cons

      • Lack of Graphics examples

      Best Uses

      • Expert
      • Intermediate
      • Student

      Comments about O'Reilly Media iOS 4 Programming Cookbook:

      I purchased this book a few days ago and I've been reading through different parts of the book. I like O'Reilly's cookbooks because you can simply pick the things that you want to read about instead of being forced to read from the beginning.

      So first impression? The book is THICK. It is really a big book! Some 600 pages in it without the index and the foreword. My purchase arrived about 4 days ago. After opening the book, you will see different subjects covered, such as multitasking (this whole chapter is my favorite chapter), core data and etc.

      This book is not for beginners though. I was smart enough (muhaha) to use the "Look Inside" feature of Amazon before making my purchase. If you open the app, the first thing you see the author say is this:

      "I assume you are comfortable with iOS" bla bla "This book does not get novice programmers started, but presents useful ways to get things done for iOS programmers ranging from novice to expert"

      And this is what I pointed out earlier. I know a bit iOS development but I'm not an expert so I still have some difficulty understanding memory management and object lifetime and etc in Objective-C. This book didn't help much with that except showing me a few examples. So if you are a real newbie, I suggest you start with something that goes into details about object creation and etc. But if you know a bit about iOS development, this is THE book for you.

      Chapter 1 is all about objects and memory management. As I said, I still have some problems with object allocation and etc so I have to keep referring to other documentations as well as consulting this book.

      Chapter 2 is all about view controllers and tab bars. I knew about view controllers but didn't have much experience with tab bars. It also shows how to create split controllers for the iPad.

      Chapter 5 is another one of my favorites as it teaches all sorts of gesture recognizers. One suggestion for this chapter would be more *practical* examples. For instance, why should somebody use a Tap gesture recognizer? I think some more practical examples could really be useful in this chapter. After Chapter 5, one of the juicy chapters that I like is Chapter 7 which shows how you can use Operations. I was a "thread guy". I still am. I create my own threads, but after reading this chapter, I am starting to think that I've wasted a lot of time so far creating threads and should have read the material in this book far earlier than now. It's a really helpful chapter this chapter 7.

      Address book was also a handy chapter (I think it's chapter 9!). One thing I find difficult about address book is that it is all C APIs created by Apple. I wish Apple could create an Objective-C wrapper around this framework. Some of the stuff in this chapter is just for iOS 4 (hence the book's name, DOH!) so be warned!

      The Graphics chapter was not impressive. I was expecting a lot more in this chapter but as I said, I don't really want to spend more money on a 1000 pages book. I probably will have to purchase another book for this but just as a suggestion, it would be good to have some more material covered in the Graphics chapter.

      So there, some pros and some cons. Overall, I am really satisfied with the book. I think it's a great book for those who want to just get the thing done and not worry too much about the implementation. What I suggest is more practical examples and in chapters such as Graphics, a lot more examples and material to be covered.

      (10 of 12 customers found this review helpful)

       
      4.0

      Chock full of code.

      By W. Scott Means

      from Columbia, SC

      About Me Developer, Educator

      Verified Reviewer

      Pros

      • Helpful examples

      Cons

        Best Uses

        • Expert
        • Intermediate

        Comments about O'Reilly Media iOS 4 Programming Cookbook:

        Disclosure: I'm an O'Reilly Author and developer of the Great iPhone Development Video series. That being said, I'm not one for pulling punches when I see issues with with people's code (ask anyone I've ever code reviewed :).

        This is the book I wish I'd had when I started developing for the iPhone. I started writing apps about two weeks after the infamous Apple Developer NDA was lifted and information started trickling out onto the Internet. If I'd have had a book like the iOS Cookbook I could have saved myself many hours of painful trial and error while learning Objective C and what is now the iOS API.

        This is not really a book for a beginning iOS programmer. It's a book for someone who's done a couple of simple apps and has the basic idiom down. If you're looking to learn Objective-C or the mechanics of writing an iPhone app, this book will not help you. But if you can already write a functional app, the code snippets in this book will trim lots of time off of your learning curve when it comes to implementing more sophisticated features like Core Data, gestures, etc.

        There are a few areas where the examples could be clearer, and it's clearly impossible to cover some of the more sophisticated functions of areas like Core Data in 620 pages. But overall this is an excellent REFERENCE for new and experienced app developers alike, and I'd recommend adding it to your library.

        (2 of 9 customers found this review helpful)

         
        2.0

        Some good content, but wrong book format

        By Michiel van Otegem

        from Landsmeer, The Netherlands

        About Me Developer, Educator

        Verified Reviewer

        Pros

        • Good explanaitions
        • Helpful examples

        Cons

        • No clear audience
        • Wrong book format

        Best Uses

        • Intermediate

        Comments about O'Reilly Media iOS 4 Programming Cookbook:

        Reading this book left me confused about the book's intentions. The book's audience is stated as for novice AND experts. That rarely works and this is no exception. That said, there is some good, practical content

        The first few chapters cover topics aimed mostly at the novice developer. In a language basics book these chapters would typically be somewhere half way through the book. So this is only useful if you just started to learn Objective-C without reading a book. The cookbook format doesn't help here, because discussing these topics benefit from a nice flow, which the cookbook format doesn't have. This goes for a lot of content covered. The content itself is not bad, but it should have been covered textbook style, not cookbook style.

        Several chapters are good in the cookbook format, such as chapter 4, which deals with maps and location. It quickly explains how to get things done in a practical manner. The book goes back and forth between content that should be part of a textbook (e.g. gestures, networking) and stuff more suitable for a cookbook (e.g. audio/video, camera).

        All in all, I think you can get quite a few handy tidbits from this book, but to be fair, this should be split into two books. One textbook, that really starts at the basics of Objective-C programming and teaches you good programming practices, and one cookbook with the good cookbook stuff from this book and with more practical recipes to give it more body.

        (5 of 7 customers found this review helpful)

         
        4.0

        good, but sometimes tough to follow

        By Michal Konrad Owsiak

        from Poland

        About Me Developer

        Verified Reviewer

        Pros

        • Accurate
        • Helpful examples

        Cons

        • Not comprehensive enough

        Best Uses

        • Intermediate
        • Novice

        Comments about O'Reilly Media iOS 4 Programming Cookbook:

        iOS 4 Programming Cookbook was the first of cookbook series I have ever read. The idea of this series is to present recipes that will allow you to "prepare" piece of code that does "something". Recipes are presented very consistent way through the description of the problem, answer for the particular problem and explanation of the given solution. Problems, that are discussed within the book, usually refer to issues that are elementary yet very commonly asked by introductory programmers. Book is divided into chapters that cover different aspects of iOS programming. You will find there answers to topics like view related issues, data management using Core Data, threading, multitasking, XML, and many other aspects of iOS 4 APIs. In general, I find this book interesting, however there are few drawbacks when it comes to details. First of all, you can't treat this book as the only source of knowledge when it comes to learning iOS programming. You should treat it as a reference for quite common problems that people encounter, but not as a complete guide to programming. I'd suggest here buying another book that describes topics in greater details (e.g. Learning iPhone Programming). Another issue here is that some topics may be very misleading. If you have never used Objective-C before you will probably find it difficult to understand it through "Working with objects" chapter. I think that this section could be skipped at all. It doesn't cover the Objective-C programming related techniques deeply. Even more, most of the topics that are discussed in this section you will find in any "programming in Objective-C" related title as well – but better explained. I would recommend this book only to people who want to have a starting point for some of the common tasks that have to be performed while programming any complex application. As a starting point for learning iOS programming – not really.

        (9 of 11 customers found this review helpful)

         
        5.0

        Brilliant! A must have for iOS Developer

        By Dozza

        from Sydney, Australia

        About Me Developer

        Verified Reviewer

        Pros

        • Accurate
        • Concise
        • Easy to understand
        • Helpful examples

        Cons

          Best Uses

          • Expert
          • Intermediate

          Comments about O'Reilly Media iOS 4 Programming Cookbook:

          One of my most anticipated sort of book, a cookbook for iOS. After falling in love with other Cookbooks, such as the Flex and SQL cookbooks, this book gets the most prominent spot on my bookshelf (or e-book shelf). For the intermediary developers, this book follows the same cookbook format in providing concise and essential reference to all the components of an iOS application, for the iPhone or iPad.Providing the "Problem-Solution-Discussion" model on everything from Objects and memory handling (boy do I forget some of that instantiation stuff memory ownership rules sometimes) to working with Core Data and Networking, you get everything you need to in a neat reference. For the novice developers, it also provides a quick 'jump into the pool' option for them to dive straight into coding without the theory. Either way, I am a bit fan of these books as I have noted in previous blogs.What I would like, not like I did expect that from this book, so it's not a hit at Vandad, but the addition of third-party frameworks such as Three20 and RestKit, to help developers more efficiently in solving problems relating to web service-to-CoreData syncing for example. Other than that, you get in the book everything you need to create a great app, leaving you to search for any obscure things via the Apple Developer Forums or StackOverflow.Would recommend this book for sure

          Displaying reviews 1-10

          Back to top

           
          Buy 2 Get 1 Free Free Shipping Guarantee
          Buying Options
          Immediate Access - Go Digital what's this?
          Ebook: $35.99
          Formats:  APK, DAISY, ePub, Mobi, PDF