当我构建我的项目时,我有这个警告:
ld: warning: instance method 'shareMessage' in category from /Users/attiliopatania/Library/Developer/Xcode/DerivedData/.../Objects-normal/armv7/Place+Factory.o conflicts with same method from another category
我无法理解我向你报告的结构问题在哪里,也许我在使用类别时犯了一个错误 当我强迫自己在.h文件中使用@class declaratin的模式和在.m文件中使用#import的有用头文件类时出现这个问题。 我希望有人可以帮助我:)。
shareMessage 是一个在Bean.h类中声明的方法,它以这种方式作为Place + Factory的父级:
放置+ Factory.h
#import "Place.h"
@interface Place (Factory)
...
@end
放置+ Factory.m
#import "Place+Factory.h"
#import "User+Factory.h"
@implementation Place (Factory)
...
- (NSString*) shareMessage{
return @"myMessage"
}
...
@end
注意:User + Factory具有与PlaceFactory相同的结构,它也是Bean的子项。
Place.h
#import "Bean.h"
@interface Place : Bean
...
@end
Bean.h
#import <Foundation/Foundation.h>
#import "HttpFunction.h"
#import "Usefull.h"
#import "AppManager.h"
@interface Bean : NSObject
...
- (NSString*) shareMessage;
@end
Bean.m
#import "Bean.h"
@implementation Bean
...
- (NSString*) shareMessage{
return [self.class description];
}
...
@end
更新: 最后我解决了。我查看我的所有类处理.h文件中的可能@class和.m文件中的#导入顺序(这似乎是真正的问题)。
答案 0 :(得分:0)
因为类Place已经有方法shareMessage,所以它从Bean继承了这个方法。 @implementation Bean(Factory)更改为@implementation Bean