2013-11-27 60 views
0

警告我有註冊按鈕,點擊這個我加入登記操作NSOperationQueue,但我的問題是,如果用戶名字段爲空警報不會appearing.Someone請建議我增加註冊相關任務到NSOperationQueue一個正確的做法或不SVProgressHUD上顯示內部NSOperationQueue

- (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 

    } 

} 

回答

0

使用此代碼:

if ([username.text isEqualToString:@""]) 
     { 
      UIAlertView *alert [[UIAlertView alloc] initWithTitle:@"Message" message:@"Please fill all the fields." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 

      [alert show]; 
     }