我有一个界面:
#import <Foundation/Foundation.h> @interface Picture : NSObject; @property (readonly) NSString *filepath; - (UIImage *)image; @end
和实施:
#import "Picture.h" #define kFilepath @"filepath" @interface Picture () <NSCoding> { NSString *filepath; } @end @implementation Picture @synthesize filepath; - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; return self; } - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:filepath forKey:kFilepath]; } - (UIImage *)image { return [UIImage imageWithContentsOfFile:filepath]; } @end
我收到错误:ARC问题 – ‘NSObject’没有可见的@interface声明选择器’initWithCoder:’
使用ARC时,NSCoding有什么不同吗?
谢谢