私は誰かが私を助けてくれることを願っている問題に苦しんでいます。
「GameObjectDefinitionTable」というクラスがあり、ここですべてのオブジェクト プロパティを設定します。これは、「Product」という別のクラスにあります。私の「HelloWorldScene」では、「GameObjectDefinitionTable」を割り当てて、いくつかの「Product」を作成します。このような:
HelloWorldScene -> GameObjectDefinitionTable -> 製品
次に、「製品」を「HelloWorldScene. しかし、ここで問題が発生します。いくつかのコード:
HelloWorldシーン:
GameObjectDefinitionTable *god = [[GameObjectDefinitionTable alloc]init];
Product* currentProduct = [god getProductWithNum:0];
NSLog(@"currenProduct (name): %@",currentProduct.name); //Crash
ゲームオブジェクト定義テーブル:
-(void) createProducts {
Product *product;
for (int i=0; i<[allProductsWithDefinitions count];i++ ) {
product = [[Product alloc]init];
product.name = [[allProductsWithDefinitions objectAtIndex:i] objectAtIndex:0];
product.density = [[[allProductsWithDefinitions objectAtIndex:i] objectAtIndex:1] floatValue];
product.scoreValue = [[[allProductsWithDefinitions objectAtIndex:i] objectAtIndex:2] intValue];
product.fileName = [[allProductsWithDefinitions objectAtIndex:i] objectAtIndex:3];
[products addObject:product];
[product release];
}
[allProductsWithDefinitions release];
}
-(Product *) getProductWithNum:(int)tNum {
Product *tempProduct;
tempProduct = [products objectAtIndex:tNum];
return tempProduct;
[tempProduct release];
}
そのクラスにログインすると、「GameObjectDefinitionTable」の配列とすべてが正常に機能します。
答えに本当に感謝します:)