Quentamia
Quentamia

Reputation: 3294

Why is ARC deallocating my object?

I have a view controller I'm storing into a mutable array.

- (void)pushViewController:(KAViewController *)viewController
{
    [self.viewControllers addObject:viewController];

    if (self.count == 0)
        [self.view addSubview:viewController.view];
    else 
        [self transitionFromView:self.currentViewController.view toView:viewController.view];
}

The array (viewControllers) is defined as:

@property (nonatomic, retain) NSMutableArray *viewControllers;

The view has a button, and when I click on it I get the following message:

[KAGameInfoViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0x6e6e900

I've confirmed that 0x6e6e900 is the address to my view controller.

Any thoughts?

EDIT

Turning off ARC fixing the problem.

Upvotes: 0

Views: 627

Answers (1)

JeremyP
JeremyP

Reputation: 86651

Probably self.viewControllers is nil because you forgot to do:

self.viewControllers = [[NSMutableArray alloc] init]; 

anywhere.

Upvotes: 5

Related Questions