0
添加messageUI.framework後,應用程序停止工作
我有一個完整的應用程序創建,我想添加一些新功能。我添加了messageUI.framework
,它停止工作。如果我刪除了框架,它再次運作,但這不是主意。添加messageUI.framework後,應用程序停止工作
我收到的錯誤是:
-[Account initWithCoder:]: unrecognized selector sent to instance 0x1cd953a0
我有一個自定義NSObject
稱爲帳戶和我加載它時出現錯誤:
myAccounts = [[NSMutableArray alloc] init];
myAccounts = [NSKeyedUnarchiver unarchiveObjectWithFile:savePath]; //Crashes in this line
當它以前保存:
[NSKeyedArchiver archiveRootObject:myAccounts toFile:savePath];
它可以是ca由一些重疊的變量或類似的東西使用?
注:
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
這就是Apple要求我們使用前綴約定的原因之一:http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/Conventions/Conventions.html –