我在JSON解析中遇到麻烦。当我完成代码并运行它时,就会出现问题:
选择器'show alert:with message'。
没有已知的类方法
以下是我的代码:
if (!isValid) {
[AppDelegate showAlert:@"Alert!" withMessage:strMessage];
}
return isValid;
}
-(void)registerUser{
[Loading startLoading:YES];
NSString *urlString = [NSString stringWithFormat:@"URL=//%@",Access_Token];
//username, password, name, email, country
NSString *parameter = [NSString stringWithFormat:@"firstname=%@&lastname=%@email=%@&username=%@&password=%@&confirmpassword=@",fnameField.text,lnameField.text,eamilField.text,unameField.text,passField.text,cpassField];
NSConnection *conn = [[NSConnection alloc] initWithDelegate:self];
[conn sendRequest:urlString withParaMeter:parameter withMethod:@"POST" withTag:1];
[conn startAsynchronousRequest];
}
-(void)NSConnection:(NSConnection*)conn didFailWithError:(NSError*)error withTag:(int)tag{
NSLog(@"error is:- %@",[error description]);
}
-(void)NSConnection:(NSConnection*)request didSuccessWithItems:(NSDictionary*)dicData withData:(NSData*)data withTag:(int)tag{
NSLog(@"all data is:- %@",dicData);
int returnCode = [[dicData valueForKeyPath:@"process.returncode"] intValue];
NSString *strMessage = @"";
returnCode = 0;
switch (returnCode) {
case 0:
break;
case 1:
strMessage = @"User not logged in/process Id not available.";
break;
case 2:
strMessage = @"Invalid parameters passed.";
break;
case 3:
strMessage = @"Access token doesn't exist.";
break;
default:
strMessage = @"User name allready exist.";
break;
}
[AppDelegate showAlert:@"Alert!" withMessage:strMessage];
[Loading stopLoading];
[self.navigationController popViewControllerAnimated:YES];
请帮帮我。
答案 0 :(得分:1)
那是因为你试图在对象AppDelegate上调用该方法
然而,AppDelegate类没有实现它。
因此错误。确保它已实施。
答案 1 :(得分:0)
此问题的两次机会
showAlert: withMessage:
@interface
方法签名
<强>修正:强>
@interface