Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

anuragsolanki

macrumors newbie
Original poster
Dec 24, 2008
2
0
I am having problem in releasing memories of views.

Just understand my problem in detail:
Consider I have view controllers-> view1controllers, view2controllers, view3controllers...and so on.
view2controllers is a part of view1controllers and view3controllers is part of view2controllers...
For example-
view1controllers.h
Code:
#import <UIKit/UIKit.h>

@class view2controller;

@interface view1controller : UIViewController {
     view2controller *v2Controller;
}

Now I switch from view1 to view2 using
view1controller.m

if (v2controller == nil)
self.v2controller = [[view2controller alloc] initWithNibName:mad:"view2" bundle:[NSBundle mainBundle]];
self.view = v2controller.view

Now I want to release the memory of view1controller (or its view). How should I do it?
Similarly, I am switching between other views. As a result object allocation tends to increase and never decrease. Is there any method so that I can release the memory of last view or didReceiveMemoryWarning could help me any ways?

Just tell me if I am not clear, but please reply soon.
 

bnut

macrumors newbie
Nov 16, 2008
28
0
That entirely depends on how you allocated the view, but after you have removed it from usage you can probably tell it to autorelease. I'm not entirely sure of all the internal intricacies of the view hierarchy when doing this, but if you use the appropriate methods when removing it as a subview then call this, it should be fine. I haven't had a problem with this method.
 

l.sanjeevrao

macrumors newbie
Oct 17, 2008
11
0
Dont Use interface Builder

Why are you going with interface builder and nibs stuff, create the views and everything from the coding itself then it doesn't make any memory problems.
here is my sample code .

HotelDetailsVIewController *elementController= [[HotelDetailsVIewController alloc] initWithIndexPath:indexPath];
[[self navigationController] pushViewController:elementController animated:YES];
[elementController release];
it never given me any problems :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.