【发布时间】:2010-03-04 15:11:49
【问题描述】:
产品项是副本,还是只是对 NSArray 中对象的引用?需要释放吗?考虑到没有alloc,我认为不需要释放,对吗?
ProductItem *item = [appDelegate.productTextList objectAtIndex:[indexPath row]];
【问题讨论】:
标签: objective-c iphone release nsarray
产品项是副本,还是只是对 NSArray 中对象的引用?需要释放吗?考虑到没有alloc,我认为不需要释放,对吗?
ProductItem *item = [appDelegate.productTextList objectAtIndex:[indexPath row]];
【问题讨论】:
标签: objective-c iphone release nsarray
它是一个指向ProductItem 类的指针。
您应该仅释放一个对象,如果您做了一些事情来增加它的保留计数。 IE。 alloc/init、copy,或致电retain。
【讨论】:
它只是一个ProductItem类型的指针,所以它不是一个副本。
保证您的引用在对 objectAtIndex 的调用范围内有效(它在对象上调用 autorelease)。如果您想保留更长时间,您需要保留并负责在完成后释放它。
【讨论】: