{"id":190,"date":"2009-02-20T23:43:25","date_gmt":"2009-02-21T06:43:25","guid":{"rendered":"http:\/\/www.kernelcrash.com\/blog\/?p=190"},"modified":"2009-02-23T16:06:44","modified_gmt":"2009-02-23T23:06:44","slug":"an-iphone-game","status":"publish","type":"post","link":"https:\/\/www.kernelcrash.com\/blog\/an-iphone-game\/2009\/02\/20\/","title":{"rendered":"An iphone game"},"content":{"rendered":"<p>After my first iphone app got out the door, Ive been quite stagnant in the ideas department. And it&#8217;s not like I&#8217;m raking money in on my one app. Let&#8217;s just say it could be a while before I get to Apples minimum threshold for payment.<\/p>\n<p>But as luck would have it, I recently met another iphone developer here in NZ. He had some good ideas &#8230; but not a lot of time. I don&#8217;t have a lot of Unix work on at the moment, so seemingly have plenty of time. So at the moment I&#8217;m working on a game with him, based on his idea.<\/p>\n<p>There&#8217;s definately a big learning curve at the moment. Firstly, I&#8217;ve never written a complex game before (I have started some back in the Amiga era), and there&#8217;s logically a fair bit more code involved than my simple &#8216;get something on the app store&#8217; 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&#8217;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;<\/p>\n<blockquote>\n<pre>- (id) retain\r\n{<\/pre>\n<pre>\u00a0   NSLog(@\"RETAIN MyClass %p rc before:%d\", self, [ self retainCount]);<\/pre>\n<pre>\u00a0\u00a0\u00a0 return [ super retain ];<\/pre>\n<pre>}<\/pre>\n<pre>- (void) release<\/pre>\n<pre>{<\/pre>\n<pre>\u00a0\u00a0\u00a0 NSLog(@\"RELEASE MyClass %p rc before:%d\", self, [self retainCount ]);<\/pre>\n<pre>\u00a0\u00a0\u00a0 [ super release ];<\/pre>\n<pre>}<\/pre>\n<\/blockquote>\n<p>I also put some NSLog&#8217;s in my dealloc&#8217;s like so. Whatever you do, DON&#8217;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!<\/p>\n<blockquote>\n<pre>- (void)dealloc {\r\n\u00a0\u00a0\u00a0 NSLog(@\"DEALLOC MyClass %p\", self);<\/pre>\n<pre>\u00a0\u00a0\u00a0 [someVar release ];<\/pre>\n<pre>\u00a0\u00a0\u00a0 [super dealloc];<\/pre>\n<pre>}<\/pre>\n<\/blockquote>\n<p>So there&#8217;s some challenges ahead &#8230; but it&#8217;s all looking good so far.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After my first iphone app got out the door, Ive been quite stagnant in the ideas department. And it&#8217;s not like I&#8217;m raking money in on my one app. Let&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-iphone"],"_links":{"self":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":8,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}