How to remove a null value from NSDictionary
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a JSON Feed: { "count1" = 2 ; "count2" = 2 ; idval = 40 ; level = " " ; "logo_url" = "/assets/logos/default_logo_medium.png" ; name = "Golf Club" ; "role_in_club" = Admin ; } The problem is the " " that I cannot figure out how to remove from the NSDictionary before saving it to NSUserDefaults. Please help me solve this issue. Thankyou! 回答1: Iterate through the dictionary and look for any null entries and remove them. NSMutableDictionary * prunedDictionary = [ NSMutableDictionary dictionary ]; for ( NSString * key in [