Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

Thread: Collision Error
View Single Post
Old 03-10-2010, 08:21 PM   #7 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Okay, then setting the timer to nil after you invalidate it will probably stop that crash. It might be hiding a deeper problem of course; I'd add an NSLog at the top of checkCollision to see if it's still getting called after the timer is invalidated.

I see where you are calling checkCollision directly; I assume that checkCollision is also called somewhere down the chain from showActivity? And not from onTimer, right? If checkCollision is getting called from onTimer then you'll have a problem, because onTimer (and checkCollision) will keep getting called even though you invalidate myTicker.

Also, if you accidentally call "start" twice then you'll have a problem, because you'll have four timers (two calling, two calling onTimer) and you'll only have a pointer to one of them. One way to fix that would be to always invalidate myTicker before creating a new one.

Code:
//kill old timer
[myTicker invalidate];
//create new timer
myTicker = [NSTimer scheduledTimerWithTimeInterval:.09 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,862
Threads: 89,223
Posts: 380,685
Top Poster: BrianSlick (7,129)
Welcome to our newest member, higgey
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.