问题
Like the title says i have a one to many relationship and the many accepts numbers, and it is given an NSNumber, however when i retrieve that number back from coredata it comes in the form of a PFCachedNumber. Any thoughts on why this may be?
Thanks!
for (UserNumber *info in pinNumberArray) {
//The numbers I'm after are inside ergTimes.
NSSet *time = [[NSSet alloc] initWithSet:info.Times];
for (ErgTimes *ergTimes in time){
NSLog(@"Times Class : %@", [ergTimes.Twok class]);
}
}
回答1:
I wouldn't worry about it. This is a common occurrence.
NSNumber, like most common API classes, is actually a "class cluster" in which a large number of classes masquerade as a single class. For example, if you initialize an NSString as a file path, you actually get back a class dedicated to handling file paths.
I haven't seen this particular class but I presume that PF
stands for "PrivateFramework" just like NS
stands for "NextStep" and CF
stands for "CoreFoundation". It's likely an internal class we're not supposed to see easily.
(I am amused that they spelled "cached" incorrectly.)
You test for a class cluster with a class test like so:
[pfCashedNumerObject class] == NSNumber
Class-clusters internal classes all identify as the same public class.
来源:https://stackoverflow.com/questions/6284470/coredata-number-returns-a-number-of-pfcachednumber-class