我正在尝试用图像归档 ns mustable 数组,我的代码如下所示:
//in my .h file I have
#define kName @"name"
#define kEmail @"email"
#define kPhone @"phone"
#define kDetail @"detail"
#define kImages @"images"
#define kRequestDate @"requestDate"
#define kRequestSent @"status"
@interface BAPRequest : NSObject
@property (nonatomic) NSString *name;
@property (nonatomic) NSString *email;
@property (nonatomic) NSString *phone;
@property (nonatomic) NSString *detail;
@property (nonatomic) NSMutableArray *images;
@property (nonatomic) NSDate *requestDate;
@property (nonatomic) BOOL requestSent;
@end
//in my .m file I have
#import "BAPRequest.h"
@implementation BAPRequest
@synthesize name, email, phone, detail;
@synthesize images;
@synthesize requestDate;
@synthesize requestSent;
- (void)encodeWithCoder:(NSCoder *)encoder{
[encoder encodeObject:name forKey:kName];
[encoder encodeObject:email forKey:kEmail];
[encoder encodeObject:phone forKey:kPhone];
[encoder encodeObject:detail forKey:kDetail];
[encoder encodeObject:images forKey:kImages];
[encoder encodeObject:requestDate forKey:kRequestDate];
[encoder encodeBool:requestSent forKey:kRequestSent];
}
- (id)initWithCoder:(NSCoder *)decoder{
name = [decoder decodeObjectForKey:kName];
email = [decoder decodeObjectForKey:kEmail];
phone = [decoder decodeObjectForKey:kPhone];
detail = [decoder decodeObjectForKey:kDetail];
images = [decoder decodeObjectForKey:kImages];
requestDate = [decoder decodeObjectForKey:kRequestDate];
requestSent = [decoder decodeBoolForKey:kRequestSent];
return self;
}
@end
当然,我也有 NSKeyedArchiver 代码,就像其他人一样。
其他所有内容都正确存档,当我保存然后加载它们时,似乎一切正常。
但存档图像似乎不是。
我确实有一个 MutableArray 在存档之前存档每个 BAPObjects,想知道是因为 ios 不支持在 MutableArray 中存档 MutableArray 还是仅仅因为我无法轻松存档图像?
干杯菲尔