I’m using ASIHTTPRequest [request startAsynchronous] functon to send a request to my webservice api to login. If the request is ok, it returns a json value. Then I send another request to get user’s info, but here I receive an error.
Here is my code:
-(void)login
{
[usernameTextField resignFirstResponder];
[passwordTextField resignFirstResponder];
username = [usernameTextField text];
password = [passwordTextField text];
if ( ([username length] == 0 ) || ([password length] == 0 ))
{
...
}
else
{
NSString *URL = [NSString stringWithFormat:@"https://xxx.xxx.xx.xx/FMS/Pages/Service/FMService.svc/Login?user=%@&pass=%@",username,password];
NSURL *requestURL = [NSURL URLWithString:URL];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:requestURL];
[request setValidatesSecureCertificate:NO];
[request setDelegate:self];
[request startAsynchronous];
}
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSError *error = [request error];
if (!error)
{
NSString *responseString = [request responseString];
NSDictionary *responseDict = [responseString JSONValue];
NSString *unlockCode = [responseDict objectForKey:@"d"];
if ( [unlockCode isEqualToString:@"successful"] )
{
NSURL *url = [NSString stringWithFormat:@"https://xxx.xxx.xx.xx/FMS/Pages/Service/FMService.svc/GetUserInfo?user=%@",username];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setValidatesSecureCertificate:NO];
[request startSynchronous];**//THERE IS AN ERROR**
NSError *error = [request error];
if (!error)
{
NSDictionary *responseDict = [responseString JSONValue];
NSString *realName = [responseDict objectForKey:@"RealName"];
NSLog(@"%@",realName);
}
}
else
{
//...
}
}
else
{
NSLog(@"%@",[error description]);
}
}
And there is an error:
[__NSCFString absoluteURL]: unrecognized selector sent to instance
0x69ef4b0
Another error:
void SendDelegateMessage(NSInvocation*): delegate
(_selectionLayoutChangedByScrolling:) failed to return after waiting
10 seconds. main run loop mode: kCFRunLoopDefaultMode
This line is incorrect:
It should be changed to: