我以这种方式实现了登录方法:
[KVNProgress show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//some error handling like:
if ([_usernameField.text length] < 4) {
[KVNProgress showErrorWithStatus:@"Username too short!"];
_passwordField.text = @"";
return;
}
//Then I call login web service synchronously here:
result = [ServerRequests login];
dispatch_async(dispatch_get_main_queue(), ^{
if(!result)
{
[KVNProgress showErrorWithStatus:@"problem!" completion:NULL];
_passwordField.text = @"";
}
else if([result.successful boolValue])
{
[KVNProgress showSuccessWithStatus:result.message];
}
});
});
它大部分崩溃了,并且只有主队列(没有优先级默认值)解决了周围的块!但问题是:KVNProgress 只显示在错误处理区域,而不是我们称为 Web 服务的下一部分。这根本不是用户友好的!欢迎任何想法:)