Strange Objects (NSCFType, etc.) Indicate Memory Management Bugs.

Any errors involving NSCFType or some class you have never heard of (eg ” *** -[NSCFType count]: selector not recognized “) are indicators of a memory management bug. Most likely an object is getting released too soon. The freed memory is then re-allocated for a new object, say an NSCFType. The pointer to the over-released object, obj, has not changed, but is now pointing to a NSCFType, which receives any messages sent to obj (and chokes on most of them).

NSCFType is not documented anywhere by Apple. As near as I can tell, it’s some deep-dark part of Core Foundation, but whatever it really is, it’s clearly not meant to venture out of it’s deep-dark lair. So seeing it means something is very wrong.

Any “selector not recognized” message may also be the result of an early-release. I have had cases where over-released memory was reallocated as an NSString, or other ubiquitous class. However, the vast majority of my “selector not recognized” issues were caused by explicitly sending the wrong message to an object (invoking count on an NSString for example).

EDITED TO ADD: In addition to NSCFType I have also seen memory bee recycled as NSExtraMIData.

About these ads
Explore posts in the same categories: Bugs, Cocoa, Debugging, MacOSX, NSCFType, Objective-C, Programming

12 Comments on “Strange Objects (NSCFType, etc.) Indicate Memory Management Bugs.”

  1. sridhar Says:

    I am also getting same error.please can any one help me.

    *** -[NSCFType count]: unrecognized selector sent to instance 0x47db00
    2008-07-09 12:13:40.007 iSoundTest[1036:20b] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[NSCFType count]: unrecognized selector sent to instance 0x47db00′

  2. Selim Says:

    You saved my life. Thank you very much

  3. deepak Says:

    Hello sir i am getting NSCFType type of error and my application get crashed after that, will you help me please to solve and understand this problem.

    ‘NSInvalidArgumentException’, reason: ‘*** -[NSCFType count]: unrecognized selector sent to instance

  4. George1024 Says:

    Holy crap, thanks man! I’ve been wondering what was going on in my app for the past 24 hours and now it works again :)

  5. Tomaz Says:

    Thank you, you are a life saver !!!!


  6. Hey, I found your blog in a new directory of blogs. I dont know how your blog came up, must have been a typo, anyway cool blog, I bookmarked you. :)

    I’m Out! :)


  7. Thanx man..ur simple hint saved me many hours of debugging….thx a lot

  8. Developer Says:

    Thank you so much! That was driving me mad !!

  9. Justin Says:

    You blog post just saved me hours of hair-pulling. Thanks!

  10. Ignacio Says:

    Thanks for this! :)

  11. Sudip Says:

    Thankssssssss for putting me into the right direction.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: