Thursday, February 5, 2009

CALayer leaks from UIButton

I don't know why, but I was leaking CALayer objects when I used the code:

UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom] initWithframe: myCGRect];

I solved this by replacing the above code with this:

UIButton *button = [[[UIButton alloc] initWithFrame:myCGRect] autorelease];

If you know why this is, I'd love to hear about it.

[iPhoneDevelopersGuide description];

This is the iPhone Developer's Guide, the companion to the Shockwave3D Developer's Guide, only for iPhone programming instead of Director programming. In essence, it's the site I wish I found when I started iPhone development, where I collect the solutions to the things that confused me, and which I figured out later.

Full disclosure: I'm learning this stuff as I go. If some Cocoa guru tells you I'm full of it, he's probably right. In that case, please let me know where I'm going astray.