Thursday, July 18, 2013

Can not save NSDictionary with NSUserDefaults!!

One of the reason is one of which is of type NSNull which is not a property list value. iterate over the keys of the dictionary I just produced so conveniently with dictionaryWithValuesForKeys and remove those of type NSNull



NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithDictionary:currentNullValueDic];
 for( id key in [dict allKeys] )
  {
       if( [[dict valueForKey:key] isKindOfClass:[NSNull class]] )
          {
                          [dict setObject:@"" forKey:key];
          }
}