Ios SVProgressHUD在NSOperationQueue内显示警报
我有一个注册按钮,通过单击此按钮,我将向NSOperationQueue添加注册操作,但我的问题是,如果用户名字段为空,则不会出现警报。有人建议我向NSOperationQueue添加与注册相关的任务,方法是否正确Ios SVProgressHUD在NSOperationQueue内显示警报,ios,Ios,我有一个注册按钮,通过单击此按钮,我将向NSOperationQueue添加注册操作,但我的问题是,如果用户名字段为空,则不会出现警报。有人建议我向NSOperationQueue添加与注册相关的任务,方法是否正确 - (IBAction)Register:(UIButton *)sender { NSOperationQueue *queue = [NSOperationQueue new]; NSInvocationOperation *operation = [[NSInvoca
- (IBAction)Register:(UIButton *)sender {
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(loadDataWithOperation)
object:nil];
[queue addOperation:operation];
}
- (void) loadDataWithOperation {
if(username.text.length==0)
{ NSLog(@"loadDataWithOperation");
[SVProgressHUD showSuccessWithStatus:@"Enter User Name"];
}
else
{
//cose for registration
}
}
使用此代码:
if ([username.text isEqualToString:@""])
{
UIAlertView *alert [[UIAlertView alloc] initWithTitle:@"Message" message:@"Please fill all the fields." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}