Hello,
I am instantiating a UIViewController (gameBoardViewController below) that is File's Owner to a custom view (associated to a view created in IB).
First time I load it there is no problem. The second time the application needs it again, I want to check that it is not "nil", which is no problem, and then release it before creating it again in order to get a "fresh" object.
Now the problem, when trying to release it, the application crashes. The retain count is 1 when trying to release it, so I guess I am not over-releasing it? Here's the code.
Before, I did initiate it using initWithNibName, but it was the same problem. I removed it since the view is actually loaded in the controllers loadView. I think I have misunderstood something relating to how to work with the nibs, so perhaps this is part of the problem. I am having the same problem in different places. The UIViewController has outlets that is linked in IB to the view loaded from the nib.
Thanks in advance!
I am instantiating a UIViewController (gameBoardViewController below) that is File's Owner to a custom view (associated to a view created in IB).
First time I load it there is no problem. The second time the application needs it again, I want to check that it is not "nil", which is no problem, and then release it before creating it again in order to get a "fresh" object.
Now the problem, when trying to release it, the application crashes. The retain count is 1 when trying to release it, so I guess I am not over-releasing it? Here's the code.
Code:
if(gameBoardViewController == nil){
gameBoardViewController = [[BoardViewController alloc] init];
} else {
NSLog(@"Retain count %i ", [gameBoardViewController retainCount]);
[gameBoardViewController release];
gameBoardViewController = [[BoardViewController alloc] init];
}
Before, I did initiate it using initWithNibName, but it was the same problem. I removed it since the view is actually loaded in the controllers loadView. I think I have misunderstood something relating to how to work with the nibs, so perhaps this is part of the problem. I am having the same problem in different places. The UIViewController has outlets that is linked in IB to the view loaded from the nib.
Thanks in advance!