how to remove object from NSDictionary how to remove object from NSDictionary ios ios

how to remove object from NSDictionary


First you need to use a NSMutableDictionary and put this code :

[countriesToLiveInDict removeObjectForKey:@"Countries"];[countriesToLiveInDict setObject:sortedArray forKey:@"Countries"];


First of all make your NSDictionary to NSMutableDictionary & then write the following line of code

[countriesToLiveInDict removeObjectForKey:@"Countries"];

This will definitely resolve your issue.


NSDictionary cannot remove anything, please use NSMutableDictionary, like this:

NSMutableDictionary *countriesToLiveInDict = [NSMutableDictionary dictionaryWithObject:countriesToLiveInArray forKey:@"Countries"];