kill
quit
The Debugger has exited with status 0.
[Session started at 2010-06-05 14:35:05 -0500.]
2010-06-05 14:35:09.967 countingtime[20625:20b] the timer is started
2010-06-05 14:35:11.327 countingtime[20625:20b] *** -[NSCFDictionary invalidate]: unrecognized selector sent to instance 0xd37a90
2010-06-05 14:35:11.328 countingtime[20625:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary invalidate]: unrecognized selector sent to instance 0xd37a90'
2010-06-05 14:35:11.330 countingtime[20625:20b] Stack: (
807902715,
2421095995,
808284155,
807854166,
807706786,
9177,
814709201,
815110321,
815119058,
815114270,
814813151,
814722763,
814748641,
839148405,
807687520,
807683624,
839142449,
839142646,
814752238,
8308
)
If you know something that might be wrong with this code. It was originally told to me in a different thread i posted where the person said it should work, but it doesn't. If you know how to fix this or know a better way to possibly do this check out the thread "can a timer do this?"
you probably want that to be two equals signs for comparison:
Code:
else if(timer_running == TRUE)
I can't see that really causing the problem though; the only way to get to that assignment is if timer_running is already true, so at worst that assignment does nothing. I have a feeling I'm missing something else.
What action causes the crash? You click the button once, and then one second later "boom?"
EDIT: The error you're getting is the one you usually get for invalidating a timer twice, but you are setting your pointer to nil so that should not happen.
Found it. You want scheduledTimerWithTimeInterval: instead of timerWithTimeInterval. The method you used returns an autoreleased timer that is not scheduled yet - you need to schedule it yourself before it will fire. So the timer never fired, and the second time you clicked the button it tries to invalidate the (already released) timer and you crash.
Found it. You want scheduledTimerWithTimeInterval: instead of timerWithTimeInterval. The method you used returns an autoreleased timer that is not scheduled yet - you need to schedule it yourself before it will fire. So the timer never fired, and the second time you clicked the button it tries to invalidate the (already released) timer and you crash.