Check if NSDictionary is empty

后端 未结 8 1373
感情败类
感情败类 2021-02-13 02:22

I want to check if an NSDictionary is empty. I am doing it like this.

  mutDictValues = [[[NSUserDefaults standardUserDefaults] objectForKey:@\"dicV         


        
相关标签:
8条回答
  • 2021-02-13 03:20
    if ( [mutDictValues count] == 0 ) {
        //code here
    }
    else {
        //code here
    }
    

    After having your dic retrieved this should do

    0 讨论(0)
  • 2021-02-13 03:28
    BOOL containsKeyABC = [myDict: valueForKey:@"ABC"];
    
    int items = dict.count;
    
    if (items > 0) {
         //not empty
    }
    
    0 讨论(0)
提交回复
热议问题