0

For some reason, whenever I call my CCLayer subclass within a block that is being executed else where the code seems to crash with EXE_BAD_ACCESS.

[[DataModel sharedInstance] saveWithSuccess:^{
                CCAlertView *alertView = [[CCAlertView alloc] initWithMessage:@"Unsaved Changes" detail:@"You have unsaved changes, would you like to save?" andButtons:@[@"Save", @"Continue", @"Cancel"]];
                alertView.delegate = (id <CCAlertViewDelegate>)self;
                [self.controls addChild:alertView z:100 tag:kAlertViewTag];
            } failure:^{
                CCAlertView *alertView = [[CCAlertView alloc] initWithMessage:@"Save Failed" detail:nil andButtons:@[@"Okay"]];
                alertView.delegate = (id <CCAlertViewDelegate>)self;
                [self.controls addChild:alertView z:100 tag:kAlertViewTag];
}];

I'm not exactly sure on what I am doing wrong, is it the block that is throwing it off? I use this line on code in other places and it works.

4

1 回答 1

0

啊意识到我需要使用添加视图

[[NSOperationQueue mainQueue] addOperationWithBlock:^{}];
于 2013-01-21T23:29:14.660 回答