Reputation: 6718
I have created NSMutableDictionary and the values of keys are formed as nsarray. I have removed objects of keys. I have no doubt for this case. But I would like to remove key When value of that key is empty or null as following as the case.
{
Africa = (
"Kenya",
"South Africa"
);
America = (
);
Asia = (
"India"
);
}
The above dictionary has three keys and one of these keys has no objects that is America. I would like remove this key. Is it possible? Can we remove key from nsmutabledictionary?
Please help me.....
Edited: Simple mistake. I understand what i have mistaken. The key(America) has value and which is empty array that means the number of elements in array is zero.
Upvotes: 8
Views: 16868
Reputation: 46543
How to remove key from nsmutabledictionary When value of that key is empty or null in ios?
This is not possible, dictionary must have Key and Value a non-nil Value.
In your case it is Array. that contains no value.
EDIT:
Whenever you see { }, that is dictionary, & ( ) is array.
Upvotes: 3
Reputation:
The above dictionary has three keys and one of these keys has no objects that is America.
FALSE. It holds an empty NSArray
. This is how you remove it:
[dictionary removeObjectForKey:@"America"];
Upvotes: 30