如果我有一个看起来像这样的方法:
- (NSDictionary *)removeDataInDictionary:(NSDictionary *)dictionary { NSMutableDictionary *mutableDictionary = [dictionary mutableCopy]; [mutableDictionary removeObjectForKey:@"key"]; // Return option 1 return [NSDictionary dictionaryWithDictionary:mutableDictionary]; // Return option 2 return (NSDictionary *) mutableDictionary; }
是选项1“更好”的代码,因为它将真的返回一个NSDictionary,而选项2将实际返回一个NSMutableDictionary伪装成一个NSDictionary?