ObjC NSNumbers returned as NSTaggedPointerString

I create a new document where some of the dictionary values are NSNumber.
Later I want to compare a possible new document so read the old one using this code…

CBLDocument *oldDoc = [database existingDocumentWithID:documentId];
NSDictionary *oldDict = oldDoc.userProperties;

Some of the returned values are an NSTaggedPointerString rather than NSNumber.
Interesting when restarting the app all numeric values are returned as NSNumber.
The NSTaggedPointerString values are numbers that are used repeatedly, so it’s an in memory Objective C optimisation.

The problem is that NSDictionary isEqual fails because NSTaggedPointerString is an NSString type rather than an NSNumber.

This project runs into a similar thing where NSNumber values end up returning NSTaggedPointerString. They discuss using a NSValueTransformer.

I can write my own isEqual routine but any ideas to help? As I think this is a bug getting back a completely different class.

Thanks,

Martin

I’ve never heard of anything like that happening – it sounds like a serious bug in NSJSONSerialization. Can you provide a test case? And can you see if it happens with earlier OS versions, by using the simulator?

In that other issue you linked to, the numbers in the JSON have quotes around them so they’re really strings. Doesn’t sound the same as your issue.