7

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.

Benoît Lahoz
  • 1,270
  • 1
  • 18
  • 43

4 Answers4

9

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.

DrummerB
  • 39,814
  • 12
  • 105
  • 142
  • Please confer to the comment on the @AliSoftware answer. Thank you for this answer. – Benoît Lahoz Sep 13 '12 at 15:59
  • Seriously though, what is NSTaggedDate? Are there any practical differences vs NSDate? – mkc842 Apr 26 '14 at 01:46
  • You can get objects that are instances of `__NSTaggedDate` from system frameworks like `ALAssetsLibrary`. Those objects are valid `NSDate` objects as can be seen if checked with `[taggedDate isKindOfClass:[NSDate class]]`. – orkoden Jul 24 '14 at 09:36
  • 1
    if (object.class == NSDate.class) { } will not work with a __NSTaggedDate. – EvilPenguin Jul 29 '14 at 15:42
6

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?).

Analog File
  • 5,280
  • 20
  • 23
3

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)
AliSoftware
  • 32,623
  • 6
  • 82
  • 77
  • Thank you all. I use this NSMutableDictionary to store references to objects. In Quartz Composer I create objects in one plugin, then pass them to another plugin that stores their references, so they can be used by a third plugin. I'm working on a Quartz Composer port of Box2D and I have to manage my objects and Box2D objects that can't be initialized at the same time. This Dictionary is aimed to keep these references. I release these objects because of the number of retain I use on it, in the different plugins. FYI, I'm using NSZombie. – Benoît Lahoz Sep 13 '12 at 15:57
-1

Whenever you try to set one data type to another data type like "if you directly assign an date component to text to an UIlabel" in this case I ll occurs

[toDateLabel setText:[tempArr lastObject]];                                   // Cause

[toDateLabel setText:[NSString stringWithFormat:@"%@",[tempArr lastObject]]]; // Solution
Maximilian Ast
  • 3,369
  • 12
  • 36
  • 47