以下は私のコードですが、レスポンス文字列に基づいてsegueを実行したいのですが、誰かが自分のコードを見て何が間違っているか教えてください。segueを実行できません
と私が連絡番号に値を入力しているとき。テキストフィールドには、アプリがエラーで終了している:私は試してみる
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't do regex matching on object <UITextField: 0x7faae2079980; frame = (20 353; 280 45); text = ''; clipsToBounds = YES; opaque = NO; autoresize = W+TM+BM; gestureRecognizers = <NSArray: 0x7faae2097250>; layer = <CALayer: 0x7faae2083bd0>>.'
コード:あなたがtextField.text
ないUITextField
オブジェクトを渡す必要がありますので、クラッシュしているあなたの2番目の質問については
- (IBAction)Register:(id)sender {
if ((uname.text.length==0)&&(uemail.text.length==0)&&(ucontact.text.length==0)&&(upwd.text.length==0)&&(confirmpwd.text.length==0)){
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Can not Register"
message:@"All the Fields are Mandatory"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel", nil];
[alert show];
}
else{
NSString *emailString = uemail.text;// storing the entered email in a string.
//Regular expression to checl the email format.
NSString *emailReg = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest=[NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailReg];
if(([emailTest evaluateWithObject:emailString]!=YES)||[emailString isEqualToString:@""])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Enter your email in [email protected] format." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
uemail.text = @"";
return;
}
}
NSString *mobile=ucontact.text;
NSString *numberRegEx = @"([0-9]{10})";
NSPredicate *numberTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", numberRegEx];
if ([numberTest evaluateWithObject:ucontact] != YES||[mobile isEqualToString:@""])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Enter a Valid Number." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
uemail.text = @"";
return;
}
if ((upwd.text)!=(confirmpwd.text)) {
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Password Do Not Match"
message:nil
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel", nil];
[alert show];}
NSURL *url = [NSURL URLWithString:@"http://108.179.246.128/connectme/service/registration.php"];
NSMutableURLRequest *rq = [NSMutableURLRequest requestWithURL:url];
[rq setHTTPMethod:@"POST"];
NSString *params=[NSString stringWithFormat:@"name=%@&email=%@&mobile=%@&passwrd=%@",self->uname.text,self->uemail.text,self->ucontact.text,self->upwd.text];
NSData *postData = [params dataUsingEncoding:NSASCIIStringEncoding];
[rq setHTTPBody:postData];
NSURLResponse *response;
NSError *error;
NSData *urlData = [NSURLConnection sendSynchronousRequest:rq returningResponse:&response error:&error];
NSString *str=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding]; NSLog(@"Login response:%@",str); //getting response
// [self performSegueWithIdentifier:@"activity" sender:self];
if([str isEqual: @"Successfully Registered"])
{
[self performSegueWithIdentifier:@"login" sender:self];
}
else if([str isEqual:@"Sorry Email address already taken"])
{
UIAlertView *alertit=[[UIAlertView alloc] initWithTitle:@"Can not Register"
message:@"Email Address already Taken"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel", nil];
[alertit show];
}
}
ucontactがtextfiledされ、あなたはその上で述語をevaluteでき..追加し、 'mobile'またはあなたがより多くの情報を与える必要があり、あなたのセグエのための' ucontact.text' –