fresh to objC and cocos2d 🙂
i’m following “learn cocos2d game development with iOS5”, in chapter4, there is a “DoodleDrop” game.
define some variable in GameScene.h like this
@interface GameScene : CCLayer
{
CCSprite *player;
CGPoint playerVelocity;
CCArray *spiders;
CGSize screenSize;
int dropedSpidersCount;
float duration;
}
+ (CCScene *)scene;
@end
in GameScene.m the init method looks like this
- (id)init
{
if (self = [super init]) {
duration = 4.0;
[self createPlayer];
[self createSpiders]; // spiders were inited here.
[self resetSpiders];
[self schedule:@selector(chooseSpider:) interval:0.7];
}
return self;
}
while in chooseSpider, i cannot access spiders, xcode broke

in other methods, spiders or duration just behave normally, why does this happens?
gist code added
After inspecting your code, I suggest you to try this fix:
where the only difference is in the line:
Indeed, if you do not retain you
spidersobject, it will be autoreleased at the next run loop iteration.OLD ANSWER:
Without seeing more code it is not possible to say exactly what is happening, but it seems that in the interval between creating the spiders and the actual execution of
chooseSpiders, yourspidersarray gets deallocated.As a quick try, I would suggest adding:
before calling
and see wether the crash keeps happening.
if you provide more code, it could be possible to help you further.