PassionateDeveloper
PassionateDeveloper

Reputation: 15148

Remove subView from View?

I have 2 Views, each View have a ViewController.

I opened the first view early in TabController.

Then (when a line in a table is clicked) I use this to add my subview:

ENSListViewController *vc = [ENSListViewController alloc];
vc.folder_id = 1;
vc.folder_type = @"an";
[vc initWithNibName:@"ENSListViewController" bundle:nil];
[self.view addSubview:vc.view];
[vc release];

In the second view I try to remove this view again, but it ends in a EXC_BAD_ACESS:

- (IBAction)backToFolderList:(id)sender
{
[self.view removeFromSuperview];
}

Where is my mistake?

Upvotes: 0

Views: 568

Answers (1)

PJR
PJR

Reputation: 13180

You are releasing vc by [vc release]; hence it is not getting object of superview.. you have to release it in -dealloc method

Upvotes: 2

Related Questions