I have an -(IBAction)get;
its functionality is to awake some methods.
-(IBAction)get{
[self msgToServer:@"MSRQ" Username:username];
[self msgToServer:@"TRNR" Username:username];
[self subscriptonList];
}
now i want to know that how can i set a timer in it? when user press "get" button it should call only [self msgToServer:@"MSRQ" Username:username];
& after 5 seconds it should awake [self msgToServer:@"TR开发者_运维技巧NR" Username:username];
and after next 5 seconds it should awake [self subscriptonList];
automatically.
i Hop question is understandable. Note: I am working in Xcode, Objective-c Thanx in advance
You can make use of
[invocation performSelector:@selector(invokeMethod) withObject:object afterDelay:delay];
Or if you want a timer
[NSTimer scheduledTimerWithTimeInterval:inteval target:self selector:@selector(urMethod) userInfo:nil repeats:YES/NO];
If you want to use dummy methods
-(IBAction)get{
[self msgToServer:@"MSRQ" Username:username];
[self performSelector:@selector(sendMessage) withObject:nil afterDelay:5];
}
- (void)sendMessage
{
[self msgToServer:@"TRNR" Username:username];
[self performSelector:@selector(subscriptonList) withObject:nil afterDelay:5];
}
精彩评论