How to insert a new key with value in dictionary

前端 未结 4 995
情话喂你
情话喂你 2020-12-18 18:17

I want to insert a key with a corresponding value in an existing dictionary...

I am able to set values for existing keys in the dictionary, but I am not able to add

4条回答
  •  萌比男神i
    2020-12-18 18:41

    Hi I am getting the content from json in the format of dictionary and from that i am adding the content into some other dictionary

      //here contract is my json dictionary 
      NSArray *projectDBList =[contract allKeys];//listing all the keys in dict 
    
      NSMutableDictionary *projectsList=[[NSMutableDictionary alloc]init];
    
      [projectDBList enumerateObjectsUsingBlock:^(NSString * obj, NSUInteger idx, BOOL *stop) {
    
      [projectsList setObject:[contract objectForKey:obj] forKey:obj];
    
      }];
    

提交回复
热议问题