どうした。辞書が設定されていない場合、いくつかのデフォルト値で辞書を初期化NSMutableDictionaryするメソッドを使用して、ここで使用しようとしています。checkNullただし、iOS シミュレーターは -loop での最初の遭遇でクラッシュしforます。
エラーメッセージ:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber mutableCopyWithZone:]: unrecognized selector sent to instance
コード:
+ (void)checkNull {
if ([[self defaults] valueForKey:@"channels"] == nil) {
NSNumber *defaultValue = [NSNumber numberWithBool:YES];
NSMutableDictionary *channels = [[NSMutableDictionary alloc] init];
for (NSString *channel in [self channelsList]) {
[channels setObject:[defaultValue mutableCopy] forKey:channel];
}
[[self defaults] setValue:channels forKey:@"channels"];
}
}
[self defaults][NSUserDefaults standardDefaults]を
返しますが、約 10 個のオブジェクトを含む を[self channelsList]返します。NSArrayNSString
どこが間違っていますか?前もって感謝します