キーと値とともに 2 つの辞書を比較したいと考えています。私の次のコードはエラーを返します。
NSLog(@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"doc_GETNEWS"]);
NSLog(@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"doc_GETNEWS_next"]);
if([[NSUserDefaults standardUserDefaults] objectForKey:@"doc_GETNEWS_next"]!=nil)
{
NSDictionary *firstCache=[[NSUserDefaults standardUserDefaults] objectForKey:@"doc_GETNEWS"];
NSDictionary *secondCache=[[NSUserDefaults standardUserDefaults] objectForKey:@"doc_GETNEWS_next"];
NSLog(@"%@",firstCache);
NSLog(@"%@",secondCache);
//not equal then store it to main cache
if(![firstCache isEqualToDictionary:secondCache])
{
[[NSUserDefaults standardUserDefaults] setObject:secondCache forKey:@"doc_GETNEWS"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
エラーが発生しています
if(![firstCache isEqualToDictionary:secondCache])
このステートメントで.like
[__NSCFArray isEqualToDictionary:]: unrecognized selector sent to instance 0x85247a0
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFArray isEqualToDictionary:]: unrecognized selector
sent to instance 0x85247a0'
そうではありません:両方のNSLOGでデータを正常に取得しました。