I have an app in which I pass an dictionary of type [string:[int]] from a swift file to an objective c file, then as NSDictionary. Through that process, the data formats get all screwed up, but in the end I am able to access each array of ints from a string, as would be expected from an NSDictionary. Unfortunately, somewhere along the line the integers get converted to type 'id', and to change that back to int, I did this:
NSLog(@"%d",(int)theThreeNotes[@"0"][0])
theThreeNotes[@"0"][0] should be 0, but it is logged as 55. How do you fix this?
If the dictionary is passed to Objective-C, all the integers will become
NSNumber
instances.NSDictionary
/NSArray
cannot hold primitive values. That means you will have to callintegerValue
on the number, not cast it blindly toint
.Or just print it using: