tags:

views:

154

answers:

1

Error: [__NSCFDate drawAtPoint:]: unrecognized selector sent to instance 0xd251e0 Termininating app due to uncaught exception 'NSInvalidArgumentException'

Scenario: for the most part this works. But I notice this error, even on the simulator, when I swapping UIImages, slowly, but consistently.

For example, I have a retained reference to a UIImage that im drawing. By the click of a picker control I am changing the face image (this occurs in another view-controller).

I can consistently recreate this error by continuously changing the faces. It usually crashes at about the 4th swap or more.

My theory: It's not loading the image, therefore the image reference is nil. I know ive read a bit about UIImage being cached, so I wouldnt think im running out of memory.

Any ideas? Thanks!

A: 

More likely than not, you have an image that has been overreleased or released prematurely -- released before your app is done with it -- and, by coincidence, an instance of NSDate was allocated at the same address as the now-defunct image.

Sounds like a big coincidence, but it isn't. Happens all the time.

Enable zombie detection in Instruments' ObjectAlloc Instrument and run your app. It'll tell you what instance of UIImage was prematurely released and, on the click through, where all the retains and releases occurred.

http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html#//apple%5Fref/doc/uid/20001883

Search for Zombie.

Or:

http://stackoverflow.com/questions/1198745/nszombies-are-eating-my-apps-brain

bbum
Thank you. Will this NSZombieEnabled being enabled degrade the runtime performance? Incidentally, i noticed im running my app (simulator and device) as a Release build, yet im still seeing outputs from NSLog. Is this normal? If so, i'd imagine that the NSLog output would definitely degrade runtime performance.
AlvinfromDiaspar