Reputation: 117
I'm tying create a welcome label using NSTimer
but its showing the through some warnings
like
undeclared selector hidelable and unused variable timer
I have not used the NSTimer
before can one pls tell me where im doing wrong and wt is the right method to do it.I need to give a welcome message when app load after few minities it has to disappear
i have tried this one im not able to get pls help me
this is the code i have to used in the view didload
NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(hideLabel:) userInfo:nil repeats:NO];
in storyboard i have used ib label which i want to display message
@property (strong, nonatomic) IBOutlet UILabel *wel;
please any one tell wt is proper way to make this one..
Upvotes: 1
Views: 8442
Reputation: 17595
According to your code, You didn't use timer anywhere else, and didn't fire repeatedly. Then you can use this code as below..
[self performSelector:@selector(hideLabel:) withObject:yourLabel afterDelay:60];
Importantly, define your target method,
-(void)hideLabel:(UILabel*)label
{
// your code here...
label.text = @"Fired...";
}
Upvotes: 1
Reputation: 3416
Try this
[NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(timerCalled) userInfo:nil repeats:YES];
-(void)timerCalled
{
NSLog(@"Timer Called...");
}
Upvotes: 0
Reputation: 4792
you have not declared hideLabel method.hence it gives that warning
[NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(hideLabel:) userInfo:nil repeats:NO];
-(void)hideLabel:(NSTimer *)timer{
myLabel.hidden=YES;
}
Upvotes: 4
Reputation: 47099
If you does not need to use (extra use of) object of NSTimer
then you should create NSTimer
such like,
[NSTimer scheduledTimerWithTimeInterval:60.0f target:self selector:@selector(hideLabel:) userInfo:nil repeats:NO];
And then you need to declare timer's method other wise after active (60 sec.) timer you will be get error.
- (void)hideLabel:(NSTimer *)theTimer
{
// Timer method code;
}
Upvotes: 0