我们是否需要在推入导航控制器后释放viewcontroller的对象?

时间:2009-07-28 10:24:37

标签: objective-c iphone xcode uinavigationcontroller

这是示例代码。

if(MyPageViewControllerObj==nil)
    {
        MyPageViewController *vController = [[MyPageViewController alloc] initWithNibName:@"MyPageView" bundle:[NSBundle mainBundle]];
        self.MyPageViewControllerObj=vController;
        [vController release];
        noOfWrongAnswers=0;
        noOfRightAnswers=0;
    }
    MyPageViewControllerObj.sessionid=sessionid;
    MyPageViewControllerObj.categoryID = categoryId;
    MyPageViewControllerObj.flashcardIdforcount = flashcardid;
    MyPageViewControllerObj.categoryType=categoryType;
    MyPageViewControllerObj.indexViewControllerobj=self;
    [self.navigationController pushViewController:MyPageViewControllerObj animated:YES];

我需要写这行**** [MyPageViewControllerObj release] ****

将其推入导航控制器之后,以及dealloc方法......

1 个答案:

答案 0 :(得分:3)

是的,您应该释放MyPageViewControllerObj,因为UINavigationController会保留它。它不需要在-dealloc方法中。