Sign-up for my latest app's private beta at consolewriteline.com!

« Phone Guy | Main | FirefoxBrowser .Net Control »

Learning Objective-C

I recently started learning Objective-C and the Cocoa framework.

It's been a lot of fun so far, and I've got myself a copy of Cocoa Programming for Mac OS X - which I strongly recommend if you want to learn Objective-C and get a good understanding of the cocoa framework - the author, Aaron Hillegass, does assume a prior knowledge of C, or at least a C-based language (C++, Java, C#) - and he skips over pointers and memory management assuming you've got this conquered.

I'm really enjoying learning it, Apple have a got a lot right with Objective-C in my opinion. One thing I'm not so sure on is the legacy C syntax/functionality underneath Objective-C's crisp, modern objective structure. In fact, it seems that Objective-C was built to lure C developers to the Mac platform. It feels a little 'hacked', in the same way C++ feels a little like it's been squeezed together into a semi-OO language (if there is such a thing). An example would be support for the class string - string in some modern OO languages such as Java and C# is a sort of pseudo value type - it seems to be becoming more widely accepted to treat string as a value type for simplicity. This is where Objective-C starts to show its true 'C' colours. For example, here is the C# way of creating a new string object.

string myString = "foo";

And here in Objective-C:

NSString *myString;
myString = [[NSString alloc] initWithString:@"foo"];

Now the difference is that NSString is a class stored in the Cocoa framework, because of this, there is a distinction between NSString (all Cocoa classes start with NS - as in NeXTSTEP) and CString (the char array). So all NSString constants need to be prefixed with "@" so the complier can distinguish between legacy C strings and instances of Cocoa's NSString class.

But old C code aside - Objective C rocks!

Interface builder is the most intuitive IDE I've ever used. You can really feel Apple's attempt to ensure developers conform to it's User Interface Guidelines - there's snapping to a grid and then there's snapping to where Steve Jobs thinks it looks best - but let's face it - he's right!
I've not been blown away by XCode, but I'm beginning to think I've been spoilt with Visual Studio 2005's features such as its very powerful code complete - it really doesn't get any better than that for lazy coders. I miss VS' code complete.

While learning Objective-C using the Cocoa framework may not be easy, it's certainly been very rewarding so far.

IB-thumb.jpg
This is Interface Builder - it takes a unique and refreshing approach to interface design, it's also the only IDE I've used that takes such an interesting approach to creating objects and connecting properties and methods without coding.

XCode-thumb.jpg
This is XCode

Screen shot of Visual Studio 2005
This is MS Visual Studio 2005 - for comparison.

Comments

I'm coming from Delphi7 on Windows. I've just switched to the Mac world and I'm looking forward to learning Objective-C and Cocoa. I'm very much afraid I'm really spoiled by Delphi's language niceties and the IDE.

Post a comment


Contact Me

If you'd like to get in touch, contact me on +447944 353544 or matt@mattbrindley.com

products

Litmus

Litmus makes compatibility testing easier for web pages and email newsletters.

ThinkFold

Online outlining, for groups. Collaborate in realtime with colleagues!

Delicious Presentation Creator

20 slides from your Delicious feed, 20 seconds each.

Flare

A site-specific browser for 37Signals' Campfire chat app, bring Campfire to your desktop.

CSSVista

Edit your CSS code live in both Internet Explorer and Firefox simultaneously.