Cocoa Programming

I’ve been doing some Cocoa Programming for Mac OSX lately. I’ve been using Aaron Hillegass’ “Cocoa Programming For Mac OSX” and have really had an easy time following along with the book. Before ordering the book, I tried to dive into OSX programming using online material, and while I was able to get some things done, I was having a real hard time trying to wrap my head around general concepts (how does the general cocoa interaction model work? how do I try to understand when to hook things up with connections in interface builder and when to code things? What things are done for me automatically?) and found that this book has been good at explaining these things.

The book itself is pretty easy to follow and has extensive screenshots, not normally something that I would think is important in a programming book, but for XCode and Interface Builder this is surprisingly helpful. Oh, I have to drag from this to that, or that is the pane in the inspector I need to be looking at. A surprsingly large amount of “programming” so far has involved knowing what key to type in which box in interface builder to get some control to watch some value in some object. And knowing which objects that Apple already provides has keys that can be watched to do what you want.

I’m coding on snow leopard (10.6) and the book was written for 10.5 so there are some disconnects there, but so far I haven’t run into any errors with the code that I can’t figure out quickly. The biggest so far has been an example in Chapter 11 which looks like it is a bit hairy to fix. The amount of commitment I need to make as a student to something that is easy (binding in Interface Builder) compared to writing a (granted, very small!) custom class and using it to basically just type cast is pretty big. It seems like a simple type cast operation could also be accommodated in the bindings / core data paradigm (and it is, using transformations, and a small custom class) but at any rate I have really been enjoying this book.

It makes it much easier to get a handle on where to start, and since I have programming experience (C / C++, Java user interfaces, and perl mostly) I have been able to get through about a chapter per session while doing the examples and challenges.

One of the controversial things seems to have been the introduction of “dot notation” in Objective-C 2.0. This post on Big Nerd Ranch explains pretty well how I feel about it. It is confusing to me. I like the @property and @synthesize tags added to the language a lot; being able to use dot notation sounds convenient, but only if the class is accessing properties. Otherwise it can be confusing. Is that a method call? Is it doing anything tricky with memory? Do I have to worry about it and check the setter / getter selector? I’m going to stick with bracketed notation until I get a better handle on these things.

I also like that Objective-C 2.0 introduced garbage collection, but I also want to do explicit memory management with release / retain for a while.

I’ve been really impressed with how easy it is to create user interfaces in XCode / Interface Builder. All I have to compare with is Java’s Swing platform, and I never used any GUI interface builders with that. I know things are getting better in that area with NetBean’s Matisse and some of the Eclipse plugins, but every time I have looked at those they don’t seem to save you from writing much of the boilerplate code that you need to navigate user interfaces. With XCode and Interface Builder you really don’t have to write much code and things are saved out as data.

I am sure that similar systems exist for Java out there by now, but I don’t know where I would start with them and they are certainly external to stock Java vended from Sun (Oracle?)

The other thing that has really impressed me is Core Data. Apple makes it really easy to do the common things, and not hard to difficult things. In my experience with Java, it is as hard to do easy things as hard things (they are both surprisingly difficult.)

I’ve got a project in mind for Cocoa on OSX, which will probably take a few months (I do not have much free time!) but once I finish up with that I am really interested in looking at iPod / iPad development. It’s too bad that there are major differences in the APIs available to the two platforms, but that might be the next thing I look into. I guess I would have to get an iPod Touch or iPad at that point though. 🙂



Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *