开发者

From iPhone to Mac programming

I've looked through the site to make sure this isn't 开发者_JAVA百科a duplicate. Apologies if I've missed something.

I've been doing iPhone development for about a year now, and I'm comfortable with Objective-C, Xcode and Cocoa (at least what's used on the iPhone), but programming for OS X seems much more involved.

What are some good free resources for someone like me? Most of the stuff I've seen is about learning Objective-C and Cocoa, and I really want to get into the parts of IB I'm not familiar with and anything else that's important on OS X that isn't on the iPhone.


While the iPhone development evironment isn't strictly a subset of the Mac, since there are some improved and iPhone-specific bits, it is nearly so (and it's mainly the good bits). Thus, the Mac is probably the easiest platform to move to from iPhone.

On the Mac, you will especially want to learn about Cocoa Bindings, which underly a lot of modern UI work, but aren't (yet) on the phone.

Addressing your specific question, some well-respected free Mac coding resources include:

  • the canonical cocoa-dev mailing list run by Apple (which, unfortunately, has only the woefully lame web access implemented by Apple, and sporadically augmented by unreliable third-party efforts, making it mostly useful via actually subscribing to it from one of your email acccounts)
  • the CocoaDev wiki
  • Rogue Amoeba's Mike Ash has an unusually useful Q&A Fridays series on his blog
  • the advanced Mac programming book from Aaron Hillegass, Advanced Mac OS X Programming
  • although Apple's docs are pretty good now, in the bad old "description forthcoming" days, a lot of us learned how Mac OS X ticked from open-source code published by reputable software houses, like Omni's frameworks which you are free to embed as-is into your apps, or cherrypick code from

(Hmm, I don't usually post here, so I was prohibited from hyperlinking the above references... can I put them in as text? Uh, nope! Well, there's always google, I guess.)


Thankfully, Cocoa on the desktop and Cocoa Touch are very similar. I would recommend just downloading some beginner sample code from Apple's website. Since you already know Objective-C/Cocoa, you should be able to follow along pretty easily. If some parts are confusing, you can skim through Apple's guides.

Things that are the same:

  • Design Patterns (target/action, delegate, data source, first responder, etc.)
  • Objective-C
  • Interface Builder

Things that are different:

  • A control can have only one target and action. On the iPhone, you can have one target/action for a touch up inside, touch up outside, etc. On the Mac, there's only one.
  • NSWindowController for loading xibs (conceptually similar to UIViewController, though)

Edit: Overall, the main different the iPhone has more 'pre-built' UI classes (UINavigationController, UITabBarController, etc.) you can use in your app to make it look nice and pretty (and most importantly, consistent with Apple apps).


I started out with Mac OS development and went to iPhone development. You probably already know the core concepts about how the APIs work. The biggest problem I see developers who transition from iPhone to Mac is getting used all the subtle ways that Mac users expect their apps to work. Things like handling the Page Up and Page Down keys to scroll your view (shame on Tweetie for not supporting this). Or handling multiple windows. Or multiple display sizes (and making sure not to position windows off screen).

For the technical programming questions, Apple's own documentation is the best place to start. For the nuances of designing for the Mac OS and doing things right, there isn't a book or web site that has all the answers, as far as I know. Mostly that comes from using apps that are Apple Design Award winners and imitating what they do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜