文字列オブジェクトを配列内の列挙型の各メンバーに一致させるメソッドを作成しました。bArray の各メンバーに、それぞれの文字列と一致するスプライトをスプライト イメージとして追加したいと思います。これどうやってするの?
+ (NSArray *)names
{
static NSMutableArray * _names = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_names = [NSMutableArray arrayWithCapacity:20];
[_names insertObject:@"image1.png" atIndex:image1];
[_names insertObject:@"image2.png" atIndex:image2];
[_names insertObject:@"image3.png" atIndex:image3];
[_names insertObject:@"image4.png" atIndex:image4];
[_names insertObject:@"image5.png" atIndex:image5];
[_names insertObject:@"image6.png" atIndex:image6];
.
.
.
.
});
return _names;
}
-(void)spriteGroups {
NSArray* sgArray;
sgArray = [[spManager names] objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]];
CCSprite* groupSprite = [CCSprite spriteWithFile:[sgArray[0]]];// this gives me an expected identifier error. I guess this is not the right way
for (int i = 1; i > [sgArray count]; i++) {
}
}