What is NSTaggedDate?

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

This happens for a custom object called body , and the output is:

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

I found very bad information about this on the Internet.

+7
source share
4 answers

This is Apple's private class. Such errors usually occur when you mess up memory management.

Why are you trying to release all the objects in the dictionary? When you add an object to the dictionary (or array), the dictionary will save it (take ownership). And when you delete an object from the dictionary, it will be released, you do not have to do it.

Have you considered using ARC ? This simplifies memory management. You do not need to worry about saving and releasing objects.

+5
source

This is the internal undocumented cocoa class. But you do not care about this, because this is not exactly what is happening, it is a red herring, which probably happens for reasons that are difficult to explain and irrelevant here.

Look at the specified address: 0xffffffffffffffffff. This is a meaning that does not make sense. You should have a segmentation error, if not for this red herring.

For some reason, you are sending a body message to an invalid pointer (maybe some corrupted data somewhere?).

+4
source

I don't know this class, but it is probably a private class (my bet will be that it is an internal representation for NSDate objects that use a pointer-labeled trick, but I just guess).

In any case, your failure does not occur on an object named body , but when you call the method called body . And the crash is probably due to improper memory management in your code that generates memory corruption.

  • You should activate Zombies when you launch the application in debugging to help you track re-released objects.
  • Normally, you don’t need to save and free NSDictionary objects yourself, since container classes like NSArray and NSDictionary save the objects they store and free them when the object is removed from them. Therefore, I don’t understand why you “want to release all objects in NSMutableDictionary”: you only need to call removeAllObjects on this NSDictionary , and you are done, you do not need to call release on the objects yourself (you do not need to call retain for objects when adding them to the dictionary )
+2
source

Whenever you try to set one data type to another data type, for example, "if you directly assign a date component to text in UIlabel", in this case I will meet

 [toDateLabel setText:[tempArr lastObject]]; // Cause [toDateLabel setText:[NSString stringWithFormat:@"%@",[tempArr lastObject]]]; // Solution 
-one
source

All Articles