【发布时间】:2011-05-29 04:17:59
【问题描述】:
如果我使用返回 NSMutableArray 的方法创建 NSObject 类,我需要在类中释放数组还是该类永远不会保留?
不知道如何解释,所以这里有一些代码:
@implementation PointsClass
- (NSMutableArray *)pointsForLevel
{
NSMutableArray *_points = [NSMutableArray new];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(521, 279)]];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(321, 491)]];
[_points addObject:[NSValue valueWithCGPoint:CGPointMake(419, 477)]];
return _points;
}
@end
如果我像这样从 ViewController 调用此方法:
PointsClass *pointsClass = [PointsClass new];
NSMutableArray *points = [pointsClass pointsForLevel];
[pointsClass release];
我只需要释放指针数组吗? _points 数组有没有保留?
【问题讨论】:
标签: iphone