Recently while trying to answer a questions here, I ran some test code to see how Xcode/gdb reported the class of instances in class clusters. (see below) In the past, I've expected to see something like:
PrivateClusterClass:PublicSuperClass:NSObject
Such as this (which still returns as expected):
NSPathStore2:NSString:NSObject
... for a string created with +[NSString pathWithComponents:].
However, with NSSet and subclass the following code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSSet *s=[NSSet setWithObject:@"setWithObject"];
NSMutableSet *m=[NSMutableSet setWithCapacity:1];
[m addObject:@"Added String"];
NSMutableSet *n = [[NSMutableSet alloc] initWithCapacity:1];
[self showSuperClasses:s];
[self showSuperClasses:m];
[self showSuperClasses:n];
[self showSuperClasses:@"Steve"];
}
- (void) showSuperClasses:(id) anObject{
Class cl = [anObject class];
NSString *classDescription = [cl description];
while ([cl superclass])
{
cl = [cl superclass];
classDescription = [classDescription stringByAppendingFormat:@":%@", [cl description]];
}
NSLog(@"%@ classes=%@",[anObject class], classDescription);
}
... outputs:
// NSSet *s
NSCFSet classes=NSCFSet:NSMutableSet:NSSet:NSObject
//NSMutableSet *m
NSCFSet classes=NSCFSet:NSMutableSet:NSSet:NSObject
//NSMutableSet *n
NSCFSet classes=NSCFSet:NSMutableSet:NSSet:NSObject
// NSString @"Steve"
NSCFString classes=NSCFString:NSMutableString:NSString:NSObject
The debugger shows the same class for all Set instances. I know that in the past the Set class cluster did not return like this.
What has changed? (I suspect it is a change in the bridge from Core Foundation.)
What class cluster report just a generic class e.g. NSCFSet and which report an actual subclass e.g. NSPathStore2?
Most importantly, when debugging how do you determine the actual class of a NSSet cluster instance?