本文主要是介绍performSelector延时调用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;
performSelector单线程调用,当函数执行完成后调用aSelector方法,afterDelay参数为延时多少秒
-(IBAction)confirm:(id)sender{
[self startLoading];
NSMutableDictionary *dic = [NSMutableDictionary new];
[dic setValue:_account_no forKey:ACCOUNT_NO];
[dic setValue:[_passwdField.text MD5Sum] forKey:NEW_PASSWORD];
AFHTTPRequestOperationManager *manager = [sswAFHttpShared sharedInstance];
[manager POST:NET_MODIFY_PWD parameters:dic \
success:^(AFHTTPRequestOperation *operation, id responseObject){
NSDictionary *jsonDic = [operation.responseData toNSDictionary];
[self stopLoading];
if (![self IsRequestSuccess:jsonDic]){
return ;
}
[LeafNotification showInController:self withText:@"请求成功!" type:LeafNotificationTypeSuccess];
[self performSelector:@selector(back) withObject:nil afterDelay:3.0];
} \
failure:^(AFHTTPRequestOperation *operation, NSError *error){
NSLog(@"error code:%ld %@", (long)[error code], operation.responseString);
}];
}
-(void)back{
[self.navigationController popToRootViewControllerAnimated:NO];
}
多线程使用
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait
这篇关于performSelector延时调用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!