1

我得到了一些我无法得到的奇怪东西。我正在使用第三方控件(https://github.com/brunow/TableKit.m),它可以:

+ (NSSet *)cellMappingsForObject:(id)object mappings:(NSDictionary *)mappings {
    NSString *objectStringName = NSStringFromClass([object class]);
    return [mappings objectForKey:objectStringName];
}

它根据类的名称创建一个映射:

[TKCellMapping mappingForObjectClass:[NSMutableDictionary class] block:^(TKCellMapping *cellMapping) {
//CODE
}];

它会根据它的映射检查数据源对象。这些对象是为我构建的:

while ([rs next]) {
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];

    for (NSString *fieldName in [props allKeys]) {
        //CODE                
        [dict setValue:fieldValue forKey:fieldName];
    }
    [list addObject :dict]; //<--This is the datasource. The map is against each dict
}

所以,我所说的到处都是NSMutableDictionary. 但是后来发生了这件奇怪的事情。

当它调用NSStringFromClass([NSMutableDictionary class])它时说NSMutableDictionary,但当它调用NSStringFromClass([rowDict class])它时说__NSDictionaryM

为什么会这样?我检查的标题__NSDictionaryM和 Xcode 导航到NSMutableDictionary(?)。我无法从__NSDictionaryM.

顺便说一句,我需要做什么NSStringFromClass才能完全替换NSMutableDictionary

4

2 回答 2

11

它是NSMutableDictionary. 它一个NSMutableDictionary. 在此处阅读有关类集群的更多信息。

于 2013-04-11T20:46:09.503 回答
1

我已经通过子类检查完成了它:

if( [[o class] isSubclassOfClass:[NSMutableDictionary class]] ) {
  // o is at least a subclass of NSMutableDictionary
}
于 2015-07-09T16:48:48.140 回答