Pergunta

App stops working after adding messageUI.framework

I have a fully working App created and I want to add some new features. I added the messageUI.framework and it stoped working. If I delete the Framework it works again, but this is not the idea.

The error I received is:

-[Account initWithCoder:]: unrecognized selector sent to instance 0x1cd953a0

I have a custom NSObject called Account and I get the error when loading it:

myAccounts = [[NSMutableArray alloc] init];
myAccounts = [NSKeyedUnarchiver unarchiveObjectWithFile:savePath]; //Crashes in this line

When it was previously saved with:

[NSKeyedArchiver archiveRootObject:myAccounts toFile:savePath];

Can it be caused by some overlapping variables or something like that?

Notes:

Account.h is like:

#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

And Account.m is:

#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
Foi útil?

Solução

I just hit this problem, I cannot tell you exactly why, but refactor your Account object to any other name, I used Accounts, and it works. Something at runtime in the MessageUI.framework is colliding with your Account object name.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top