我在一个基于标签栏的应用 我有它的.xib A类和与它的.xib B类工作如何释放类对象被手动保留
在A级我加载B类的多个实例。
ie在A类,我在做。
在myGrid阵列我有救了网格的所有对象.m文件
-(void)renderData:(NSArray *)Data
{
for(int i=0;i<[Data count];i++)
{
B *grid=[[B alloc]initWithNibName:@"Beta" bundle:[NSBundle mainBundle]];
.
.
. //do something with the grid object i.e assign new image etc..)
[self.myGrid addObject:grid]; //i have a NSMutableArray myGrid declared in .h
[grid release];
}
}
现在。
现在我将它们添加到类Aplha视图。
for(int i=0;i<[myGrid count];i++)
{
B *grid1=[[myGrid objectAtIndex:i]retain]; //i have done this retain because when i try to come back to this tab or try to call the same function it crashes by saying message send to deallocated instance.
[self.view addSubview:grid1.view];
}
现在我的问题是如何释放我保留的grid1对象。
您可以在同一次迭代中调用此对象的释放方法,并简单地减少保留的计数。你面临什么问题? – Naved
我试图释放它,但当我试图加载该视图与一些新的数据它告诉我,该消息发送到释放实例 –
应该[[beta分配]为[B alloc]' – JeremyP