I have 100 key and value in nsmutabledictornary and i want to check that any value have null or not. Do you have any short function or technique?
I don't want to multiple line code like check every key and value. Your answer would be appreciated.
I have 100 key and value in nsmutabledictornary and i want to check that any value have null or not. Do you have any short function or technique?
I don't want to multiple line code like check every key and value. Your answer would be appreciated.
This code will give you the set of keys which have (non)null values. You can't store actual
nil
values in a dictionary, so[NSNull null]
is assumed. The predicate is trivially alterable to any other condition.From here, you can use the keys to generate a corresponding dictionary, if needed.
If you don't need a separate list of keys, and just need the filtered dictionary, skip the first step and modify the second part to read as follows:
Write category on NSDictionary it will provide you null free dictionary. Here is the category I have written for myself.
code for .h file (interface)
Code for .m file. (implementation)
Call null free method on your dictionary using above category.
//To remove NULL from Dictionary
//To remove NULL from Array