【发布时间】:2011-11-09 22:07:36
【问题描述】:
我有以下来自 Xcode (Cocoa touch) 的代码:
//Here, the class Vector2 is a class I made that stores an x value and a y value (As with XNA).
Vector2 *pointOne = [[Vector2 alloc] initWithX:170 Y:224];
Vector2 *pointTwo = [[Vector2 alloc] initWithX:193 Y:173];
Vector2 *pointThree = [[Vector2 alloc] initWithX:233 Y:67];
Vector2 *pointFour = [[Vector2 alloc] initWithX:276 Y:164];
Vector2 *pointFive = [[Vector2 alloc] initWithX:299 Y:226];
Vector2 *pointSix = [[Vector2 alloc] initWithX:276 Y:168];
Vector2 *pointSeven = [[Vector2 alloc] initWithX:193 Y:173];
//Add positions to array
NSArray * points = [[NSArray alloc] initWithObjects:pointOne, pointTwo, pointThree, pointFour, pointFive, pointSix, pointSeven, nil];
//release memory for Vector2's
[pointOne release];
[pointTwo release];
[pointThree release];
[pointFour release];
[pointFive release];
[pointSix release];
[pointSeven release];
我的问题是,释放 Vector2 是否会使数组对象也变为空?
【问题讨论】:
标签: objective-c arrays xcode cocoa-touch memory-management