Wednesday, October 28, 2009

More iPhone 3 Development Update

The writing of More iPhone 3 Development is starting to move faster now, at least in terms of the number of pages we're churning out. It's not going as fast as we'd like, and nowhere near as fast as Apress would like, unfortunately, but it is going faster. The good news is that we're really happy with what we've written so far. More iPhone 3 Development is not just more of what was in Beginning iPhone 3 Development. We have a much greater focus in this book on application design and on writing code for maximum reuse. Many of the objects we write can be used unmodified in your own applications. We assume that the reader has done some development and is ready to take things to another level.

We're just finishing up the networked applications chapters. Our original plan was to just cover GameKit networking over Bluetooth, which is relatively straightforward since Apple provides high-level objects that handle all the gnarley aspects for you. We were originally not going to cover online play over regular network connections. Our original thinking was that because there's no high-level objects yet for sending and receiving over the network that are suitable to network play, that to do an online play chapter well would require a really long chapter. Long both in terms of number of pages, and in terms of how long it would take us to write, and we didn't feel like we could afford another long chapter in light of our schedule.

To be perfectly honest, I had hoped that GameKit would add support for online play and then the whole thing would become a moot point since the GameKit chapter would be all you needed. Apple may still add that functionality to GameKit at some point (there are certainly hints in GameKit), but they haven't yet, and frankly, there just isn't a good place to go and find out how to do online play. All the information is out there, but nobody's put all the steps together in a single, easy, comprehensive place, at least as far as I've been able to find.

So, after some back and forth discussions with Dave, we came to the conclusion that we needed to cover online play in addition to the straight GameKit chapter in our original Table of Contents. We decided to do it as a follow-on chapter to the GameKit chapter. We take the game that we created in the GameKit chapter and add online play to it. We show how to use Bonjour to let the user find other peers (pretty much the same way GameKit does over Bluetooth) and show how to connect to them and exchange data in a similar manner to GameKit so we don't have to substantially rewrite the application's logic. The use of Bonjour limits play to opponents on the same network subnet (basically, phones connected to the same router or WiFi base station), but the techniques are the same for play over the internet, and we're going to have a sidebar that shows how to connect to remote machines based on a DNS name or IP number and port. The other thing this offers over GameKit is that the code can be used on a Mac, so you can write code that lets an application on a Mac talk to one on an iPhone, which opens up a whole slew of possibilities.

As with the Core Data chapters, our focus has been on writing code generically to maximize reuse, and I think we've done a good job as far as the online play stuff is concerned. We've created a class that works very similarly to GameKit's GKSession class. You pass it NSData instances to send, and it takes care of sending and receiving the data, re-assembling the packets, and making sure its delegate receives the data in the same order it was sent in. You should be able to just drop this class (along with another supporting class) into your other projects and use them as-is, making it relatively easy to implement network play. To add online play to an existing GameKit app with this should also be relatively trivial since that's what we do in the chapter.

For those who have asked what fruit will be on the new book, it'll be a blood orange.

I don't know if the cover to the left is final, but it's what is on Amazon right now, so I figure it's okay to share. Until it's approved, it definitely could change, but this is the cover image you'll see if you pull it up on Amazon. Note that the description on Amazon definitely isn't final, either.



6 comments:

Damian said...

Sounds fantastic. I cannot wait for this to hit the shelves! Keep up the good work!

Philippe said...

Great!
The first book is probably the better entry point for iPhone development that is available right now, and with your chapter on network development in the next book, that one will probably be an instant classic too!

Good Job guys!

kelly said...

This will definately prove to be Excellent Guide for iPhone Developers for their iphone projects from Concept to Completion.

http://www.rapidsofttechnologies.com/mobile-software-development/iphone-development-offshoreoutsourcing.aspx

Erik said...

I for one am very glad that you and Dave decided not to shy away from showing how to implement networked play, despite Apple not providing high-level constructs yet. I realize that for you it is a balancing act - if, in the next version of the iPhone SDK, Apple provides some facilities for doing this, one might think that your chapter becomes instantly out of date or redundant. This isn't the case, though. Those readers who are interested in seeing how such functionality could be implemented will still learn a LOT from seeing how professional iPhone developers/authors would have implemented them, even if it's recommended that these readers use the Apple-provided constructs in a shipping application.

Furthermore, I think it's unfortunate that most Mac/iPhone-related technical books tend to relegate themselves to documenting Apple's APIs and high-level constructs. All of the books on Core Animation, Core Data, etc, are great to see on the bookshelf, but on the other hand these are also the subjects that Apple documents quite extensively themselves. Maybe I'm in the minority, but I really do appreciate it when authors go a bit beyond explaining how to use some framework or other, and show how someone might actually "roll their own" functionality for situations that aren't easily solved using the off-the-shelf APIs out of the box. So I thank you and applaud your decision.

Edwin said...

scrub m65 kamagra attorney lawyer body scrub field jacket lovegra marijuana attorney injury lawyer

SEO Services Consultants said...

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck! Web Design Company