我想檢查一個NSDictionary
是否爲空。我正在這樣做。檢查NSDictionary是否爲空
mutDictValues = [[[NSUserDefaults standardUserDefaults] objectForKey:@"dicValues"]mutableCopy];
NSLog(@"dictValues are %@",mutDictValues);
if(mutDictValues == NULL){
arrCities = [[NSMutableArray alloc]init];
NSLog(@"no cities seleceted");
}else{
arrCities = [[NSMutableArray alloc]init];
arrCities = [mutDictValues objectForKey:@"cities"];
[self placeCities];
}
但它在這一行arrCities = [mutDictValues objectForKey:@"cities"];
,出現以下錯誤alwasy崩潰:
-[__NSCFConstantString objectForKey:]:
有人可以幫助我?
如果([dictTemp isKindOfClass:[NSDictionary的類]!){// 做一些 DisplayAlert(@ 「沒有找到數據」) } – kb920