iphone - Memory bad acces: Questions with releases, protocols and delegates -
i have little question memory management ios...
well define own view have 1 protocol. in other class, create instance of other class, add view other view , then, try release de instance. problem appear when call method of protocol because receive bad_accs error. this:
- (void)viewdidload{ class1 *c1 = [[class1 alloc]init]; [c1 setdelegate:self]; [self.view addsubview:c1.view]; [c1 release]; } - (void)methodofprotocolclass1 { nslog(@"c1 method called") }
the class1 have 1 button , when press call methodofprotoclclass1 , makes error. know how release object?
thanks,
david
you don't have release c1, instead must retain it! addsubview not retain c1 instance, retains view! if refer c1 later bad access
Comments
Post a Comment