Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is NSTaggedDate?

I have an error that I can't understand, that is happening while I want to release all objects in an NSMutableDictionary.

It's happening for a custom object called body and the output is :

-[__NSTaggedDate body]: unrecognized selector sent to instance 0xffffffffffffffff

I found very poor informations about it on the Internet.

like image 360
Benoît Lahoz Avatar asked Sep 13 '12 15:09

Benoît Lahoz


3 Answers

That's a private class of Apple. Errors like this usually occur when you mess up your memory management.

Why are you trying to release all objects in a dictionary? When you add an object to a dictionary (or an array), the dictionary will retain it (take ownership). And when you remove the object from the dictionary it will be released, you don't have to do that.

Did you already consider using ARC? It makes memory management a lot easier. You don't have to worry about retaining and releasing objects anymore.

like image 69
DrummerB Avatar answered Nov 10 '22 03:11

DrummerB


It's an internal undocumented cocoa class. But you are not concerned with it as it's not really what's happening, it's a red herring that is probably happening for reasons that are complex to explain and irrelevant here.

Look at the reported address: 0xffffffffffffffff. That's a value that makes no sense. You should have got a segmentation fault, if it was not for that red herring.

You are for some reason sending the message body to an invalid pointer (maybe some corrupted data somewhere?).

like image 21
Analog File Avatar answered Nov 10 '22 03:11

Analog File


Don't know this class, but it is probably a private class (my bet would be that it is a internal representation for NSDate objects that use the "tagged pointers" trick, but I'm just guessing).

Anyway your crash is happening not on an object called body, but when calling a method called body. And the crash is probably due to bad memory managment in your code that generates memory corruption

  • You should activate Zombies when running your app in debug to help you track over-released objects
  • You normally don't have to retain and release objects of an NSDictionary yourself, as container classes like NSArray and NSDictionary retain the objects they hold, and release them when the object is removed from them. So I don't see why you "want to release all objects in an NSMutableDictionary" : you only need to call removeAllObjects on that NSDictionary and you're done, no need to call release on the objects by yourself (neither do you need to call retain on the objects when adding them in the dictionary)
like image 3
AliSoftware Avatar answered Nov 10 '22 03:11

AliSoftware