私の「connect4」スタイルのゲームでは、7x6 グリッドを表す配列があり、配列内の各「セル」には、NSNull または UIView サブクラス「CoinView」が含まれています。NSMutableArray とプライマリ ビューからオブジェクトを削除する正しい方法は次のとおりですか?
- (IBAction)debugOrigin:(id)sender {
int x = 0;
int y = 0;
//get the coin object form the grid
CoinView *coin = [[grid objectAtIndex:x] objectAtIndex:y];
//cancel if there's no coin there
if ([coin isKindOfClass:[NSNull class]]) { return; }
//remove the coin from memory
[coin removeFromSuperview];
coin = nil;
[[grid objectAtIndex:x] setObject:[NSNull null] atIndex:y]; //will this leak?
}
ありがとう!