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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-11-2010, 09:30 PM   #8 (permalink)
itzdark
Will Work for Food!
 
itzdark's Avatar
 
Join Date: Apr 2009
Posts: 579
itzdark is on a distinguished road
Send a message via AIM to itzdark Send a message via MSN to itzdark
Default

Use scheduledTimerWithTimeInterval instead. The one you used will only fire when added to a run loop.


Quote:
Originally Posted by jazztpt View Post
Hi, I think I'm having the same problem and I was hoping you could provide a little code or advice. I have tried this to make sure it's on the main thread, but neither of my NSLogs are happening, so it should already be on the main thread and the timer is never being fired.
Code:
	
-(void)viewWillAppear:(BOOL)animated {
...other code...
	_countdown = 15;
	if ([NSThread currentThread] != [NSThread mainThread]) {
		NSLog(@"not the main thread");
		[self performSelectorOnMainThread:@selector(createTimer) withObject:nil waitUntilDone:YES];
	} else {
		[self createTimer];
	}
}
-(void) createTimer {
	_countdownTimer = [[NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(updateCountdown) userInfo:nil repeats:YES] retain];
}
-(void)updateCountdown {	
	NSLog(@"yo");
	if (_countdown > 0) {
		_countdown--;
	} else {
		[_countdownTimer invalidate];
		[_countdownTimer release];
		_countdownTimer = nil;
		...do other stuff...
	}
}
Any thoughts on why this timer is not firing?
__________________

Check out my apps

Developers, check out study buddy. I use it everytime I code. It's great for those late night coding sessions.
Unofficial Ad Hoc Distribution Guide || Join my cooperative ad hoc testing group
iSoothe Promotional Video
Contact Me
itzdark is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,539
Threads: 94,054
Posts: 402,646
Top Poster: BrianSlick (7,980)
Welcome to our newest member, cecilytw61
Powered by vBadvanced CMPS v3.1.0

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