0

添加 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
4

1 回答 1

1

我刚刚遇到了这个问题,我无法告诉你确切的原因,但是将你的 Account 对象重构为任何其他名称,我使用了 Accounts,它可以工作。MessageUI.framework 在运行时与您的 Account 对象名称发生冲突。

于 2013-05-28T19:53:59.270 回答