0

I have two classes with the same name. I am having conflicts because of that. I cannot rename because JSON Model is using that name and other reason over 100 classes are importing it .

Can they be combined? Or a Solution for JSONModel?

Class 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

Class 2

@implementation User
+(JSONKeyMapper*)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{@"id": @"identifier",
                                                   @"first": @"firstName",
                                                   @"last": @"lastName",
                                                   }];
Rayen Kamta
  • 115
  • 1
  • 2
  • 9
  • 1
    Of course they *can* be combined, but only you can say whether they *should* be combined. – Caleb Jun 17 '16 at 21:26
  • It's not at all clear what you're trying to do here. Why do you have two classes with the same name? Did you recently add JSONModel to your project? Do you want your existing User class to be able to be created by JSONModel, or do you want the "user" in your JSON input file to map to another class? – Mark Bessey Jun 19 '16 at 01:11

1 Answers1

0

When we had this problem, we solved it with a #define and making sure to import the right include file in each source file. It's a bad solution, but shipping is a feature too. Something like:

#define User MyUser

Rename one of the two. It's the right thing to do.

EricS
  • 9,650
  • 2
  • 38
  • 34