添加 messageUI.framework 后应用停止工作
我创建了一个可以正常工作的应用程序,我想添加一些新功能。我添加了messageUI.framework
它并停止工作。如果我删除框架,它会再次起作用,但这不是想法。
我收到的错误是:
-[Account initWithCoder:]: unrecognized selector sent to instance 0x1cd953a0
我有一个NSObject
名为 Account 的自定义,加载时出现错误:
myAccounts = [[NSMutableArray alloc] init];
myAccounts = [NSKeyedUnarchiver unarchiveObjectWithFile:savePath]; //Crashes in this line
以前保存时:
[NSKeyedArchiver archiveRootObject:myAccounts toFile:savePath];
它可能是由一些重叠的变量或类似的东西引起的吗?
笔记:
Account.h
就好像:
#define kAccName @"name"
#define kAccID @"identifier"
#define kAccInitAmount @"initAmount"
#define kAccActive @"active"
#import <Foundation/Foundation.h>
#import "Transfer.h"
@interface Account : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *identifier;
@property (nonatomic) double initAmount;
@property (nonatomic) BOOL active;
- (id)initWithID:(NSString *)ident;
@end
并且Account.m
是:
#import "Account.h"
@implementation Account
@synthesize name;
@synthesize identifier;
@synthesize initAmount;
@synthesize active;
- (id)init {
self = [super init];
if (self) {
self.active = TRUE;
}
return self;
}
- (id)initWithID:(NSString *)ident {
self = [super init];
if (self) {
self.active = TRUE;
self.identifier = ident;
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
if (self = [super init]) {
self.name = [decoder decodeObjectForKey:kAccName];
self.identifier = [decoder decodeObjectForKey:kAccID];
self.initAmount = [decoder decodeDoubleForKey:kAccInitAmount];
self.active = [decoder decodeBoolForKey:kAccActive];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:self.name forKey:kAccName];
[encoder encodeObject:self.identifier forKey:kAccID];
[encoder encodeDouble:self.initAmount forKey:kAccInitAmount];
[encoder encodeBool:self.active forKey:kAccActive];
}
@end