-2

cocos2d-iphone でゲームの実装を開始しました。プロジェクトで ARC を使用しています。

@interfacemy で宣言されたクラスのメインでLevelfinder.h、次のプロパティを宣言しました。

@property NSMutableArray* pineapples;

私のメインクラスでは、このプロパティを使用しています:

for (PineappleModel* pineapple in levelFileHandler.pineapples) 
{
    b2Body* body = [self createPineappleAt:
            [CoordinateHelper levelPositionToScreenPosition:pineapple.position]];
    body->SetLinearDamping(pineapple.damping);
    [pineapplesDict setObject:[NSValue valueWithPointer:body] 
                       forKey:[NSNumber numberWithInt: pineapple.id]];
}

しかし、コードを実行すると、次のランタイム エラーが表示されます。

SIGABRT '-[LevelFileHandler setPineapples:]: unrecognized selector sent to instance 0x9431c60

私は cocos2d を初めて使用しますが、この問題を長い間見ていて行き詰まっています。どんな種類の助けも大歓迎です。


ここはLevelFileHandler.h

@interface LevelFileHandler : NSObject

@property NSMutableArray* pineapples;

@end

今、LevelFileHandler.m私のパイナップルプロパティをこのように使用しました

self.pineapples = [NSMutableArray arrayWithCapacity:5];
[self.pineapples addObject:pineappleModel]

このコードの意図は、明らかに、容量が 5 の配列を作成することです。

4

2 に答える 2

0

のようなものがあるよう[[self class] setPineapples:something]ですcreatePineappleAt:

または、アトミック参照に問題がある可能性があります。プロパティはアトミックであり、デフォルトで合成されます。試していただけますか:

@interface LevelFileHandler : NSObject

@property (strong, nonatomic) NSMutableArray* pineapples;

@end
于 2013-05-25T15:51:05.157 に答える