嗨,我的iphone应用程序中有这个奇怪的警告:
-method 'imagePath' not found (return type defaults to 'id'
它在下面一行给我这个警告:
UIImage *image = [UIImage imageNamed:[_occasion imagePath]];
这是我的Occasion类标题:
#import <Foundation/Foundation.h>
@interface Occasion : NSObject {
NSString *_title;
NSDate *_date;
NSString *_imagePath;
}
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSDate *date;
@property (nonatomic, retain) NSString *imagePath;
+ (id)occasionWithTitle:(NSString *)title
date:(NSDate *)date
imagePath:(NSString *)imagePath;
- (id)initWithTitle:(NSString *)title
date:(NSDate *)date
imagePath:(NSString *)imagePath;
@end
奇怪的是我只在场景的(imagePath属性)上获得此警告,而其他2个属性正常工作,即:
[_occasion date]
和
[_occasion title]
我不知道为什么它抱怨这个方法是属性并且它确实存在时找不到。
答案 0 :(得分:0)
我终于找到了解决方案。我在MyFile.m中导入了Occasion.h文件,因为我只在MyFile.h中使用了正向declearation @class Occasion.h。 虽然它仍然很奇怪 在AnotherFile.h中只有@class Occasion.h就足够了而没有在AnotherFile.m中导入