An iphone game

After my first iphone app got out the door, Ive been quite stagnant in the ideas department. And it’s not like I’m raking money in on my one app. Let’s just say it could be a while before I get to Apples minimum threshold for payment.

But as luck would have it, I recently met another iphone developer here in NZ. He had some good ideas … but not a lot of time. I don’t have a lot of Unix work on at the moment, so seemingly have plenty of time. So at the moment I’m working on a game with him, based on his idea.

There’s definately a big learning curve at the moment. Firstly, I’ve never written a complex game before (I have started some back in the Amiga era), and there’s logically a fair bit more code involved than my simple ‘get something on the app store’ app. Per usual, all the retain/release stuff is a challenge. I typically write some code that kind of works, then go back later to try and sort out the retain/release mess I’ve created. I end up adding a lot of debug code. A good hint is to override the retain and release methods in your own classes. For example;

- (id) retain
{
    NSLog(@"RETAIN MyClass %p rc before:%d", self, [ self retainCount]);
    return [ super retain ];
}
- (void) release
{
    NSLog(@"RELEASE MyClass %p rc before:%d", self, [self retainCount ]);
    [ super release ];
}

I also put some NSLog’s in my dealloc’s like so. Whatever you do, DON’T put the [super dealloc] before the NSLog as I originally did and scratched my head for ages wondering why my dealloc always crashed. Doh!

- (void)dealloc {
    NSLog(@"DEALLOC MyClass %p", self);
    [someVar release ];
    [super dealloc];
}

So there’s some challenges ahead … but it’s all looking good so far.