尝试从单例加载数据时应用程序崩溃

时间:2016-10-03 22:12:27

标签: ios objective-c singleton

我有ViewControllerAViewControllerB。在每个我有这个属性

@property (retain, nonatomic) NSMutableArray *racersArray;

在ViewControllerA中,我用自定义对象填充racersArray。当我按下ViewControllerA上的汉堡按钮时,我将已填充的_racersArray存储到单个数组,然后我向ViewControllerB发送通知,表明我的_racesArray内容尚未包含在单身内容中阵列。我用这个方法:

- (void)burgerMenu
{
    [ArraySingleton sharedManager].sharedArray = _racersArray;

    // Send a notification to burger menu view controller to reload it's tableview
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadTableViewData" object:nil];
    // Opens the burger menu
    [self.frostedViewController presentMenuViewController];
}

ViewControllerB收到通知时,我称这种方法为:

- (void)reloadTableviewData
{
    _racersArray = [ArraySingleton sharedManager].sharedArray;
    [self.tableView reloadData];
}

但是在我尝试将单个数组中的数据加载到_racersArray后,我的应用程序崩溃并出现错误:

[Racer count]: unrecognized selector sent to instance 0x7fe46aef7330
2016-10-03 23:58:44.091 Stopwatch[67948:6727940] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Racer count]: unrecognized selector sent to instance 0x7fe46aef7330'

这就是我的单身人士的样子

@synthesize sharedArray;

+ (ArraySingleton *)sharedManager
{
    static ArraySingleton *sharedMyManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMyManager = [[ArraySingleton alloc] init];
    });
    return sharedMyManager;
}

- (id)init
{
    if (self = [super init]) {
        sharedArray = [[NSMutableArray alloc] initWithObjects:@"picee", nil];
    }
    return self;
}

谁能告诉我我做错了什么?

由于

0 个答案:

没有答案