I have created an app with http and I am using asihttprequest. The app only seems to work in console. The app closes without errors in the console. Did using asihttprequest affect my app?
is it ok that I use it or must I switch to something else?
i have a simple login application. Everytime I enter my username and password nothing is changes, but in the console I think its response is ok.
-(IBAction)btnClicked:(id)sender
{
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://192.168.18.8/apisample2/friendb.php?un=jackie&pd=jackie123&gd=f&ag=23&st=single&lf=kaloy&fm=jsn"]];
[request setPostValue:[self.usernameField text] forKey:@"u"];
[request setPostValue:[self.passwordField text] forKey:@"pw"];
[request setDelegate:self];
[request startAsynchronous];
}
-(void)requestFailed:(ASIHTTPRequest *)request
{
NSLog(@"Request failed: %@",[request error]);
}
-(void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"Submitted form successfully");
NSLog(@"Response was:");
NSLog(@"%@",[[request responseString]JSONValue]);
}
In the code shown you don’t do anything to prevent your ASIFormDataRequest object being destroyed before your asynchronous request has completed. If you need it to stick around you should retain it. Better yet, make
ASIFormDataRequest requesta property of whatever Class this code is extracted from.