As you can see from the question title, it's quite a mouthful to get into a method name. The code as it stands is as follows:
- (NSString *) formatObjectIfNull:(NSDictionary *)form keyToCheck:(NSString *)key {
if ([form objectForKey:key] == [NSNull null]) {
return @"";
}
return [form objectForKey:key];
}
I'm really not happy with that name. Something like objectOrEmptyStringIfNull might fit the bill? Or is there something altogether better? Or is there a good refactor that can be implemented to avoid this sort of thing altogether?
Aucun commentaire:
Enregistrer un commentaire