Monday, November 03, 2008

Learning Objective-C

So it seemed like a good idea to learn Objective-C in my spare time, so (yes, I am a nerd) spent all day on a weekend... in my free time... learning a new programming language. ;)

AND IT WAS FUN!!!!!!!!!!!!!!!!!!!!!!!!!!!!

It's not quite as insane or hard to understand as I originally expected. It's pretty much like C++ but with just a stranger syntax and a lot of stuff works differently. It looks like you really need to know your design patterns for this too. So brushing up on this stuff will be a good idea anyway. Exciting and fun times. It's a lot easier than I thought it would be and already I'm getting used to the weird syntax.

Strangest/coolest things today?
  • The "NS" in NSArray, NSSet stands for "Next-Step" - 'ol school Apple style!! Awesome.
  • Apparently a regular NSArray and NSSet cannot be added to, they must be fully initialized on startup. That's REALLY weird. So you need a special "Mutable" version of arrays to be able to modify them after initialization... random.
  • I have absolutely NO CLUE when to use a pointer, or when to just store a non-pointer member variable.
  • Right now anything I tried is leaking memory like crazy. I have little-to-no idea of how to clean up or de-reference-count the pointers. So who knows how efficient/crashy Objective-C code can be? Well presumably I'm gonna find out. :)
  • It's fun and rocks, and makes me want to buy a Mac. So I think that means that Apple is on the right track. :)

1 comment:

Alex Finlayson said...

NSString *helloJutan = [[NSString alloc] initWithString:@"Word up Jutan!!!!"];

NSLog(@"Hello world Jutan style: %@", helloJutan);

[helloJutan release];

// If you are passing the string back from a method you can do
return [helloJutan autorelease];
// This will release the object after the system is done with it.