Yeah, so this one through me or a loop for a while until I figured out what was going on. With Apple releasing the final version of Xcode today, and iOS 4 coming out yesterday, I finally started to look into porting my apps to iOS 4.
So I downloaded the new SDK, and got to work. After working on my app a bit, imagine my surprise when I got a bad access error, (trying to talk to a deallocated object). I hate those errors, so hard to figure out what to do. So, I spent the last 45 minutes trying to find what object I had deallocated. I couldn't recall what I had changed, and the error messages weren't helping. I enabled NSZombies (Zombies!!!) and got this error:
2010-06-22 15:38:28.655 ProjectPidgey[17783:207] *** -[CCTargetedTouchHandler claimedTouches]: message sent to deallocated instance 0xd834b30
Which is about as useful as it seems. I'm in Cocos2D, so I think something is being touched that no longer exists? But I couldn't find anything like that in my code. So, on a whim, I used my older version of Xcode. Compiled and installed it on the Simulator running iOS 3.0. Worked fine. Like a charm, just as I had made it.
So now, my question is, what's happening here. What is the difference between SDK 4 and 3 that would cause a Bad Exc Error? Any ideas? Or perhaps it's an issue with cocos2d and that needs to be updated?
Edit: I did some messing around and found that by removing this line of code:
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint touchPoint = [touch locationInView:[touch view]];
touchPoint = [[CCDirector sharedDirector] convertToGL:touchPoint];
if ( ![super containsTouchLocation:touch] ) return NO;
[self.engine playerHitRedDot:self];
//[self.parent removeChild:self cleanup:YES]; //REMOVED THIS LINE
return YES;
}
Then it works. So it looks like the CCTargedTouch Handler is linked to my sprite (which is then removed when I touch it) and someone everything doesn't work out... However, I need the sprites to get removed (or at least disappear, but I want to be memory conscientious), so how can I do this?
Thanks!