views:

408

answers:

1

here is sample code.

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];

do i need to write this line **[MyPageViewControllerObj release]**

after pushing it into navigation controller.and also in dealloc method...

+2  A: 

Yes, you should to release your MyPageViewControllerObj as the UINavigationController retains it. It does not need to be in the -dealloc method.

Stephen Darlington
thanks for you answer also tell me does this line effects anythingin dealloc method[self.navigationController popViewControllerAnimated:YES];
Rahul Vyas
When you pop the view controller, the reference count will be reduced. If it's zero (which it probably will be) it will get dealloc'd automatically. There is no need to add it to any dealloc method directly. Suggest you read up on Objective C memory management. It's pretty easy when you get the hang of it.
Stephen Darlington