NSObject set property values with NSDictionary

Jul 7th, 2014
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // NSObject set property values with NSDictionary
  2. - (void)setValuesWithDictionary:(NSDictionary *)dict
  3. {
  4.     if (dict != nil) {
  5.         [dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
  6.             NSString *setPropName = [NSString stringWithFormat:@"set%@%@:", [[key substringWithRange:(NSRange){0, 1}] uppercaseString], [key substringFromIndex:1]];
  7.             if ([self respondsToSelector:NSSelectorFromString(setPropName)])
  8.                 [self setValue:obj forKey:key];
  9.         }];
  10.     }
  11. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add to your ad blocker whitelist or disable your adblocking software.