I want to release UIViewController object in iOS 5.
Prior iOS versions (>5.0) we write always code or maintaining code with memory free leaks following,
if(myViewControllerObject != nil){
[myViewControllerObject.view removeFromSuperView];
[myViewControllerObject release];
myViewControllerObject = nil;
}
myViewControllerObject = [[MyViewControllerObject alloc] initWithNibName:@"MyViewControllerObject" bundle:nil];
[self.view addSubview: myViewControllerObject.view];
But in iOS 5 we can not use release method for release UIviewController object then what we have to do in iOS 5 to maintaining extra object allocation and leaks?
What will be the best method to implement this hierarchy?
Thanks.
Your code will not change to iOS 5 unless you activate Automatic Reference Counting for your project. Then you will not be able to use
release,deallocand so on, because the system handles memory management.To learn more about ARC, see this question: How does the new automatic reference counting mechanism work?