KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Memory management is a very important issue in iPhone. So I am asking a very general question. There are two ways to call a the viewController of another class. Way 1: AnotherClassViewController *viewController = [[[AnotherClassViewController alloc] initWithNibName:@"AnotherClassView" bundle:nil] autorelease]; [self.navigationController pushViewController:viewController animated:YES]; Way 2: #import "AnotherClassViewController.h" @interface ThisClassViewController : UIViewController{ AnotherClassViewController *myViewController; } @property (nonatomic, retain) AnotherClassViewController *myViewController; @end @implementation ThisClassViewController @synthesize myViewController; - (void) pushAnotherViewController{ if(self.myViewController == nil){ AnotherClassViewController *tempViewController = [[AnotherClassViewController alloc] initWithNibName:@"AnotherClassView" bundle:nil]; self.myViewController = tempViewController; [tempViewController release]; } [self.navigationController pushViewController:myViewController animated:YES]; } - (void)dealloc{ self.myViewController = nil; } @end So the obvious question is, which is the best way to call the viewController of other class ? Way1 or Way2? Suggestions and comments are openly invited. Please comment and vote.
Tags (comma-separated)
Save Edits
Cancel