tags:

views:

215

answers:

1

An object which used to identify itself as NSCFArray under previous iPhoneOSes now seems to identify itself as __NSArrayI under devices running iOS 4.0.

Any idea what's up with this? I can't find it in any documentation.

In addition, it doesn't match "[NSArray class]".

It should be a simple array. It's defined like this:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                         thisPlayerName,@"name",
                         [NSNumber numberWithInt:[myTable.visiblePlayer.number intValue]],@"number",
                         playerCountArray,@"players",
                         [NSArray arrayWithObjects:@"easy",@"medium",@"hard",nil],@"opponent difficulty",
                         [NSNumber numberWithBool:[cardDecks getOptionBoolForKey:@"seeMoney"]],@"see money",
                         [cardDecks gameSpeedOptions],@"computer turn speed",
                         [NSArray arrayWithObjects:@"aqua",@"green",@"orange",@"purple",@"red",nil],@"player color",
                         nil];

Then fed into another dictionary like this:

    myRecord = [[NSMutableDictionary alloc] initWithCapacity:5];
    [myRecord addEntriesFromDictionary:newDictionary];

Everything else has classes like I'd expect: NSCFString, NSCFNumber, NSCFBoolean, but not the arrays, and I can't figure out how to match it.

+4  A: 

Why does it appear like that? Because we can't trust the internal names of classes from one release to another.

How to match it? Don't try and match the name of the class or to equivalate the class. Just use isKindOfClass: which will match against a class and its subclasses, and does the right thing for weird variants like this.

For example:

    } else if ([thisValue isKindOfClass:[NSArray class]]) {

Note that you're sending the isKindOfClass: message to an object, not to [object class]!

Shannon A.