This sounds like the decoder decodes the number into an NSDecimalNumber
(and strings into NSString
s).
Remember, Objective-C is C, so you can effectively assign anything to a pointer, it is up to you to ensure that the types correspond. This is why you can assign an object of type NSNumber
to a pointer declared to be of type NSString*
. As you can see, class clusters don't have anything to do with this.
So before assigning your object to a variable, you should check the class or, alternatively, just assign the object to a pointer of type id
(which can hold any object).
If you need to work on the objects based on their type, you can do something like this:
id obj = //...
if ( [obj isKindOfClass: [NSString class]] ) {
}
else if ( [obj isKindOfClass: [NSNumber class]] ) {
}
else {
}