Forgot your password?
typodupeerror
Image

Beginning iPhone Development 216

Posted by samzenpus
from the read-all-about-it dept.
Cory Foy writes "When my wife got a Touch several months back, the first thing I wanted to do was build some applications for it. Who wouldn't want to play with a device that has accelerometers, position sensors and multi-touch gestures? But being new to the Mac world, I needed something to help guide me along. Beginning iPhone Development aims to be that guide. But does it live up to the challenge of teaching a newbie Mac and iPhone developer?" Read below for the rest of Cory's review.
Beginning iPhone Development: Exploring the iPhone SDK
author Dave Mark, Jeff LaMarche
pages 536
publisher Apress
rating Five $1000 Rubies
reviewer Cory Foy
ISBN 978-1-4302-1626-1
summary A great introduction to the iPhone SDK and getting into iPhone Development
The first thing you'll need to do is head over to the Apple Developers Site and register for an account. You can then download the iPhone API. Note that while the API download and simulator are free — deploying to a real iPhone or iTouch is not, even if it is your own. To do that you have to apply to the iPhone Developer Program which is $99. For the book, you'll be fine with just the simulator with the exception of any accelerometer application, since the simulator doesn't have that feature.

With that out of the way, I was quite impressed with the book. Although I've done quite a bit of development in the past, I haven't worked with Objective-C before, and was a little concerned if I would be in over my head. If you are in that position, don't fear — the authors do a great job of walking you through, and you'll find yourself working with it in no time.

The first chapters introduce you to the basics of the iPhone and development, starting with the canonical "Hello, World" application. The book walks you through how to get and install Xcode and the iPhone API. It then introduces you to Interface Builder, the partner-in-crime to Xcode. Even in the first chapter, the authors show their attention to detail, explaining common issues you might run into (like trying to Build and Run while your iPhone or iTouch is plugged in to your Mac).

Chapter 3 introduces the Model-View-Controller paradigm, a pattern that is probably one of the most misunderstood patterns in UI development. They give you enough information to be familiar with the terms you'll be using, and they very much mean it when they tell you not to worry if you aren't understanding something — they always loop back around to make sure you understand it.

Chapter 4 was a long chapter for me, but introduces some important concepts around user interaction and controls. By the end, you have an interface which has a variety of controls which interact with each other. As with the other chapters, the authors introduce tips and tricks to make things easier (for example, Option->Cmd->Up Arrow to switch from the header to implementation file in Xcode).

Chapter 5 covers autorotation and basic animations, including linking in the Core Graphics Framework. I especially like how the authors gave three different ways of making your app auto-rotation aware, describing the benefits and drawbacks of each. Chapter 6 follows this up by introducing multi-view interfaces, something very necessary as you get into more complex iPhone development.

Chapters 7-9 describe various methods to presenting information to users, including toolbars, table views, hierarchical navigation and hierarchical lists. However, it isn't all drag-n-drop, the authors get into some good (and sometimes deep) conversations about what you are doing. For example, in Chapter 8, they talk about issues with NSDictionary and how to create deep mutable copies.

Chapters 10-13 are the last of the "fundamentals" — application settings, basic data management, custom drawing using Quartz and Open GL, and taking inputs (including gestures and multi-touch). As someone who spends most of his time as far away from graphics libraries as possible, I was quite impressed with the basics that were introduced and what someone like me could get up and running.

Finally we get into the fun. Chapter 14 introduces Core Location, allowing to figure out where in the world you are. The book goes through a discussion about the various ways to get location information, and drawbacks of each. (Helpful tip: no matter which method, if you are polling every second, you'll drain the battery pretty quickly). For the simulator-only users, this is when things start to become tricky. Chapter 14 does work, though you aren't prompted for access to Core Location.

Chapter 15, however, is useless without an actual phone, even though it's perhaps the most fun. In this chapter, the book goes through the accelerometer and all the interesting things you can do with it. There's even a small discussion on the physics (but just enough!). Both apps you create (Shake and Break and the Marble game) are quite fun for someone just starting out with all of this. It's a shame Apple couldn't figure out a way yet to include the accelerometer in the simulator.

Chapter 16 covers using the iPhone camera and Photo Library. It's short, but it shows the power of the simple interfaces Apple provides. In just 9 pages you'll be capturing images right from the iPhone.

The final two chapters I thought were quite fitting — Localization and Follow-Ups. In the localization chapter, the book covers extracting strings out to resource files and using locale to read them in. Having a day job which ships our software in 12 different languages, I know first-hand how difficult localization can be to get right, so I was glad to see this chapter. The final chapter is just a wrap-up of resources you can reach out to for help and information.

All in all I was very surprised and pleased with the book. I've had the fortune of reading many technical books, and few do a great job of walking someone through the basics without making them feel like a dolt. It felt like every time I was stuck or unsure there was a tip, hint or paragraph which explained what was going on.

The main drawback to me is the fee to deploy apps to your own phone. This wasn't something I ran into doing either J2ME or Windows Mobile apps in the past, and it is a shame that to even work on your own phone you have to pay a fee. However, since the fee does give you the ability to submit apps to the App Store, then I guess it's a consolation. I'd rather Apple lock deployments to one iPhone (or iTouch) for the truly casual people who just want to do interesting things on their own phone.

In summary, I give this book five $1000 Rubys for making a clean, concise, easy-to-read and follow introduction to iPhone development. Great job guys!

You can purchase Beginning iPhone Development: Exploring the iPhone SDK from amazon.com. Slashdot welcomes readers' book reviews — to see your own review here, read the book review guidelines, then visit the submission page.

*

This discussion has been archived. No new comments can be posted.

Beginning iPhone Development

Comments Filter:
  • Interface Builder (Score:5, Interesting)

    by fragbait (209346) on Monday January 19, 2009 @04:08PM (#26519471) Homepage

    The biggest problem I've had so far is Interface Builder. It isn't the most intuitive piece of software. Dragging and dropping to connect button actions to methods between two pieces of software (XCode and Interface Builder) that don't actively sync with one another, at least not as I've yet to find.

    I already had the C/C++ and GUI/fat client app building experience from 10 years back.

    +fragbait

  • by IamTheRealMike (537420) <mike@plan99.net> on Monday January 19, 2009 @04:58PM (#26520115) Homepage

    Unfortunately Objective-C is designed such that it combines the worst parts of C with the worst parts of dynamic languages, so your point doesn't really hold. Method dispatch is all dynamic, and in the best case seems to be twice as slow as a C++ vcall. But it only gets that speed by building runtime dispatch caches, ie, trading off memory against CPU. On phones memory is also very limited.

    It really is an amazingly stupid language. I am not surprised no-one except Apple uses it. This is the language that thinks it's a good idea to redefine boolean to be YES and NO.

    That sort of weird syntax quirk is not a big deal though, it's just a time-waster. The real problems start when you realize that calling a method on a NULL object doesn't crash. Instead it returns zero, another NULL or if the method returns a struct, garbage. So what would be a clean kill with a nice stack trace in any sane language in Objective-C turns into silent propagation through your code of NULL pointers and zeros, until you save state and blow away the users data.

    On the iPhone there's no garbage collection. Yes it's back to the days of ref counting, whoopie-doo. The best they have to offer is a kludge called an "auto release pool", which basically just scopes lifetime to the current GUI event. Pretty useless for anything that lasts longer than a button push. It also massively complicates exception handling due to the rules around how auto-release pools stack (yes really [apple.com]).

    Then there's the lack of features. No namespaces. No abstract classes. No stack allocation thus no RAII. No operator overloading. No generics, really no type safety at all (calling a non-existant method is a warning not an error). Your code is trivial to decompile. And of course the only really supported development environment is a Mac.

    Java might be a stupid language to use on a phone as well, but seriously, I'll take that kind of stupid any day over Objective-C.

  • by Anonymous Coward on Monday January 19, 2009 @05:24PM (#26520477)

    Lucky you. We got our certificate after 4 months and 2 weeks. SURE. No, REALLY! No kidding.

    And btw, our game was almost finished.

  • Reinvigorated (Score:4, Interesting)

    by TellarHK (159748) <tellarhk@hotmai[ ]om ['l.c' in gap]> on Monday January 19, 2009 @05:44PM (#26520795) Homepage Journal

    I have to say that this book, which I picked up last week, has really given me a kick in the pants as far as getting back into programming. I haven't hardly done a damn thing since college in '02, and since I went to a pretty craptastic school that doesn't mean much.

    MS Visual C++ really made programming a slog, compared to the IDE that Apple came up with for XCode. I'm just a couple chapters into the book now, but all in all I'm really enjoying the process of programming again for the first time since GW-BASIC. I can understand why a lot of people here (especially here) complain about having to buy a Mac, having to use XCode, having to do things Apple's way but for something like the iPhone and iPod Touch development I can't imagine a better route.

    This is for the most part a very good book, at least for my rusty brain, but it definitely needs some kind of Objective-C accompaniment if you're not familiar with the language and want to do more than just follow instructions. Well worth the money.

    And again, to those people complaining about XCode and doing things Apple's way, dig around the ADC site and you'll see that Apple's learned a hell of a lot since the days when CodeWarrior was the only hope for a Mac developer's sanity.

  • by jupo (717073) on Monday January 19, 2009 @05:53PM (#26520903) Homepage
    Ars recently posted a short write-up [arstechnica.com] on using C# and Mono to develop for the iPhone.
  • by samkass (174571) on Monday January 19, 2009 @07:32PM (#26522245) Homepage Journal

    Actually, I agree with the original poster on many points, and it's more than aesthetics. While I love Interface Builder, Objective-C development is like pulling teeth. Things don't fail fast, the compiler catches way fewer bugs up-front, and it's a much harder language to introspect and offer lint-like analysis on than many modern languages. To someone who develops in Java all day, Objective-C is like having teeth pulled. I put up with it because I really like the iPhone, but Apple would be doing way better with developers (outside a small core of enthusiasts) if they'd ditched Objective-C when NeXTstep became MacOS X.

  • Re:Reinvigorated (Score:2, Interesting)

    by Zero Zero (106980) on Monday January 19, 2009 @09:15PM (#26523471) Homepage

    This is for the most part a very good book, at least for my rusty brain, but it definitely needs some kind of Objective-C accompaniment if you're not familiar with the language and want to do more than just follow instructions.

    The co-author recommends Learn Objective-C on the Mac [blogspot.com] as just such an accompaniment.

  • Re:First Step (Score:3, Interesting)

    by supernova_hq (1014429) on Tuesday January 20, 2009 @05:33AM (#26526531)
    That's all fine and dandy if you are developing an app with a medium budget and a profit in mind. But what if you just want to make a little app that monitors your cat's position in the living room by duck-taping it to its back?
  • by Anonymous Coward on Tuesday January 20, 2009 @09:50AM (#26527983)

    There are Cocoa bindings in a variety of other languages.

    Two examples, from vastly different languages:

    The first is Chicken Scheme, with an extended tutorial showing iTunes processing using Chicken:

    http://3e8.org/zb/cocoa/manipulating-itunes-plist.html [3e8.org]

    The second, with a less extended set of examples, is HOC - a Cocoa bridge for Haskell:

    http://hoc.sourceforge.net/examples.html [sourceforge.net]

    Note that Apple is involved several bridges from other dynamic languages (ECMAScript, python, ruby) to Cocoa.

    The point is to be able to reuse the Cocoa frameworks, which are largely written in Objective-C and C++, and in some cases build entirely new frameworks using a non-C-derived language.

    If you're allergic to Objective-C, you don't actually need to use it directly, although it's helpful to understand it in order to follow how the bridges use syntactic sugar to make the mapping to Cocoa seem more Objective-C-like.

    Admittedly, shoving this into the iPhone at this point is incredibly awkward, but Apple is not actively opposing the use of other controller languages on the iPhone, as long as they are well behaved (mostly wrt well-defined bounds on CPU and space use, and a clear understanding of the change to the attack surface of the program and the phone as a result of the language choice, and so forth).

We will have solar energy as soon as the utility companies solve one technical problem -- how to run a sunbeam through a meter.

Working...