1
enemyBlobArray = [[NSMutableArray alloc] init];

for(int i = 0; i < kEnemyCount; i++) {
    [enemyArray addObject:[SpriteHelpers setupAnimatedSprite:self.view numFrames:3 withFilePrefix:@"greenbox" withDuration:((CGFloat)(arc4random()%2)/3 + 0.5) ofType:@"png" withValue:0]];
}

enemyView = [enemyArray objectAtIndex:0];

I am trying to make objects appear on screen from this array. I get an error message saying that the object I add cannot be nil. I don't know why it's nil, though.

1
  • 1
    [SpriteHelpers setupAnimatedSprite:numFrames:withFilePrefix:withDuration:ofType:withValue:] (what a mouthful!) is returning nil. We can't possibly help you without knowing what that method does! Commented May 28, 2012 at 4:10

2 Answers 2

2

The method setupAnimatedSprite:numFrames:withFilePrefix:withDuration:ofType:withValue: is returning nil. So the problem is somewhere inside that method. Since we don't have the code for that method, I couldn't tell you what it might be.

1

According to the provided code, you make no mention of the allocation and initialization of "enemyArray"; however, you created a mutable array called "enemyBlobArray" which is never utilized within the provided code. Perhaps this is a simple issue of misspelling of a variable name.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.