在我的第一个函数中,我创建了一个NSMutableDictionary并将其保存在一个数组中。MutableDictionary变得不可变
NSMutableArray* tempPlayersArray = [NSMutableArray arrayWithArray: [[NSUserDefaults standardUserDefaults] arrayForKey: @"kgpsTempArray"]];
NSMutableDictionary *tempPlayerDictArray = [[NSMutableDictionary alloc] init];
if (!(userDeviceName)) {
[tempPlayerDictArray setValue:userDeviceName forKey:@"DeviceName"];
}else{
[tempPlayerDictArray setValue:@"empty" forKey:@"DeviceName"];
}
[tempPlayersArray addObject:tempPlayerDictArray];
[defaults setObject:tempPlayersArray forKey:@"kgpsTempArray"];
[defaults synchronize];
在我的第二个函数中,我把它作为NSCFDictionary - 这是不可变的。
NSMutableArray* tempPlayersArray = [NSMutableArray arrayWithArray: [[NSUserDefaults standardUserDefaults] arrayForKey: @"kgpsTempArray"]];
NSMutableDictionary *dictionaryForSearching = [[NSMutableDictionary alloc] init];
NSLog(@"%@",[dictionaryForSearching class]);
dictionaryForSearching = [tempPlayersArray objectAtIndex:index];
NSLog(@"%@",[[tempPlayersArray objectAtIndex:index] class]);
NSLog(@"%@",[dictionaryForSearching class]);
第一个日志显示“NSDictionaryM”。
第二个日志显示“NSCFDictionary”。
而第三个显示“NSCFDictionary”以及...
任何人都可以解释我为什么?以及如何解决它?
非常感谢! – 2013-03-06 11:11:24