Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-10-2009, 05:15 PM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 12
Default Need help with timer

I need help trying to figure out how to declare my countDown thingy. I need to know how and where to declare it. can anyone help me? I followed the tutorial by Nitrex88 and I just omitted the animation part of the code. and i keep getting the " 'countDown' undeclared first use in function. " error. I've included the timer part of the .m file and the entire .h file.

Code:
//Timer
-(IBAction)timeStart {
	time = 60.0;
	timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:(countDown) userInfo:nil repeats:YES];	<<<<ERROR HERE----
}

-(void) countDown {
	time = time - 1;
	if (timer == 0){
		[timer invalidate];
	}
	[self updateTimeLabel];
}

-(void) updateTimeLabel {
	timeLabel.text = [NSString stringWithFormat:@"%i Sec", time];	
}
Here's my .h

Code:
@interface iTap_Really_FastViewController : UIViewController {
    IBOutlet UILabel *timeLabel;
	NSTimer *timer;
	NSUInteger time;
	IBOutlet UILabel *tapsLabel;
	IBOutlet UIImageView *tapButton;
}


@property (nonatomic, retain) NSTimer *timer;
@property (nonatomic, retain) UILabel *timeLabel;
@property (nonatomic, retain) UILabel *tapsLabel;
@property (nonatomic, retain) UIImageView *tapButton;
-(void)updateLabelsFromTouches:(NSSet *)touches;
-(IBAction)timeStart;
-(void)countDown;
-(void)updateTimeLabel;
mapper724 is offline   Reply With Quote
Old 07-10-2009, 06:23 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,565
Default

The "selector:" parameters expects a selector, which you need to get with the "@selector" directive. Try this:

Code:
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
     target:self
     selector:@selector(countDown)  // I added @selector() here
     userInfo:nil repeats:YES];
Also, you want "if (time == 0)" not "if (timer == 0)" . You want to check your counter, not the timer object.
__________________
smasher is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,163
Threads: 38,935
Posts: 170,827
Top Poster: smasher (2,565)
Welcome to our newest member, iphonenikku
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:09 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0