内存管理在iPhone中非常重要。因此,我有一个非常普遍的问题。调用另一个类的viewController有两种方法。
方法1:
这里显然的问题是,调用其他类的viewController哪种方式最好? Way1还是Way2?
欢迎提出建议和评论。
请留下您的评论和投票。
方法1:
AnotherClassViewController *viewController = [[[AnotherClassViewController alloc] initWithNibName:@"AnotherClassView" bundle:nil] autorelease];
[self.navigationController pushViewController:viewController animated:YES];
第二种方法:
#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
这里显然的问题是,调用其他类的viewController哪种方式最好? Way1还是Way2?
欢迎提出建议和评论。
请留下您的评论和投票。