【发布时间】:2011-10-11 08:42:37
【问题描述】:
我正在尝试将NSMutableArray 添加到NSDictionary 但在日志中显示NSDictionary 时出现此问题:
)' of class '__NSCFArray'. Note that dictionaries and arrays in
property lists must also contain only property valúes.
这是我用来创建NSMutableDictionary的代码
NSMutableDictionary *training = [[NSMutableDictionary alloc] init];
[training setObject:[NSNumber numberWithInt:eltiempo] forKey:@"tiempototal"];
[training setObject:[NSNumber numberWithFloat:totalkm] forKey:@"distanciatotal"];
[training setObject:[NSNumber numberWithInt:(int)(velocidadmedia/60)] forKey:@"velocidadmedia"];
[training setObject:[NSString stringWithFormat:@"%2d:%02d min/km"] forKey:@"fecha"];
[training setObject:posiciones forKey:@"posiciones"];
其中 posiciones 是我要添加的数组。我将此字典保存在一个数组中,以便将其保存在用户默认值中。但由于我有这个问题,NSDictionary 没有被创建。
感谢您的帮助。
佩德罗
【问题讨论】:
-
也许这不是问题,但我看到键“fecha”的字符串格式无效。
-
您没有粘贴整个日志消息。问题似乎是数组或字典包含不属于祝福属性列表类型组(NSString、NSArray、NSDictionary、NSDate、NSData、NSNumber)的对象。
标签: iphone ios arrays nsmutablearray nsdictionary