可以在Objective-C中组合两个用户类吗?

时间:2016-06-17 21:20:12

标签: objective-c json xcode jsonmodel

我有两个同名的课程。因此我有冲突。 我无法重命名,因为JSON模型正在使用该名称,并且有超过100个类的其他原因正在导入它。

他们可以合并吗?还是JSONModel的解决方案?

第1类

#import "User.h"


@implementation User


+(User*)createWithDictionary:(NSDictionary*)dictionary inContext:(NSManagedObjectContext*)context{
//Censored
}
+(User*)createWithDictionary:(NSDictionary*)dictionary{
//Censored
}
-(void)updateWithDictionary:(NSDictionary*)dictionary{

//Censored
}
 -(NSString*)classOfProperty:(NSString*)propName{
//Censored
}


@end

第2类

@implementation User
+(JSONKeyMapper*)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{@"id": @"identifier",
                                                   @"first": @"firstName",
                                                   @"last": @"lastName",
                                                   }];

1 个答案:

答案 0 :(得分:0)

当我们遇到这个问题时,我们用#define解决了这个问题,并确保在每个源文件中导入正确的包含文件。这是一个糟糕的解决方案,但运输也是一个功能。类似的东西:

Startup

重命名其中一个。这是正确的做法。