NSZombie to the Freaking Rescue

So I’ve been beating my head against a wall the past few days trying to cram as much Objective-C knowledge as possible and I think it’s all starting to click.

Today I stumbled over the NSZombieEnabled argument and HOLY CRAP WHY ISN’T THIS DEFAULT BEHAVIOR. After enabling the argument I found where my app crashed in about 1 minute. Turns out you should not do:

- (void)viewDidUnload {
    self.foo = nil;
    [super viewDidUnload];
}

but rather

- (void)viewDidUnload {
    foo = nil;
    [super viewDidUnload];
}


A fairly subtle difference I’ll grant myself but, apparently, an important one. In this particular case I am using the self.foo property as a typed copy of the UIViewController’s view property. In the wrong case setting self.foo to nil releases the property where the framework assumes it still exists, resulting in an app crash. Simply setting the foo instance variable to null, however, works great.

No Comments        

Recent Posts

Exile Issue 1 Released

The game I’ve been working on at my day job has been released. The first issue of Exile is available today, and if you order now for $8 you get the remaining 3 issues delivered digitally when they are released. Exile is unlike most games and most graphic novels, in that it offers first rate [...]

Don’t Get Shot Released

The minigame I’ve been working on at my first issue of Exile. The game is a reversal on the popular top down shmup genre, in that you are the one getting shot at. It is your goal to not get shot, or exploded, and progress through the levels. The level names I find entertaining and [...]

Lice Helper Launched

Recently finished and launched a new website for a client. The website advertises a lice removal service and provides means for potential customers to learn about the service and get in touch with the business quickly and easily. Lice Helper The site is built on a CakePHP application and actually uses WordPress for the blog [...]

ImageMagick Split and Join a Sprite Sheet

Continuing the Flixel theme that seems to be brewing here, I found a good way to transform images from full dimension art to sprite sheets. This is useful when converting an image into a sheet compatible with the Flixel tile and map system. In my case I am using it to split up background images [...]

Flixel Pixel Perfect Collisions

I haven’t found a decent source of information about this on the interwebs so I thought I’d share my findings. Flixel doesn’t have any built in pixel perfect collision support, it just assumes that you are using square (or at least rectangle) sprites and don’t use any rotation. Well, that’s not entirely a real world [...]

Flixel Puddles and Oil Slicks

I’ve been using the super cool Flixel framework to make a game and it’s quite handy for most things. The game I’m working on is basically a top down…ehh, well let’s just say it’s top down. I can post more details when the game is actually released. As a category, top down and platformer games [...]

Computer Engineer Barbie

A coworker writes me saying: Please take a moment to vote for Barbie to become a Computer Engineer. Future generations of computer engineers would really appreciate it if we could influence some girls to take up the profession. So indeed, I did vote, and so should you….or else! From the Barbie site: Computer engineers have [...]

Flash Draw Transparent BitmapData

Recently ran into an issue where I thought I should have been drawing a transparent BitmapData object, but the resulting object had a white background. The original incorrect code was the following: var bd:BitmapData = new BitmapData(w, h, true);   The third boolean argument to the function is a transparency flag, and here it is [...]

Flex Scale Image to Max Dimension

Recently had a problem where I needed to display images as large as possible within given bounds. So I made a handy little function that computes the scaling needed so that the image, if it is larger than any of the bounds, is scaled so that its largest dimension becomes equal to the given maximum. [...]