【发布时间】:2011-12-03 23:08:31
【问题描述】:
我正在使用 ASIHttpRequest POST 用户并传递给执行 php 代码的 url。此代码返回一个 url 字符串,但现在,还需要图像才能在 tableview 上显示它。如何使用 ASIHttpRequest 在 iphone 上保存来自该 url 的图像?
- (void)getData
{
activityIndicator.hidden = NO;
[activityIndicator startAnimating];
NSURL *url = [NSURL URLWithString:@"http://test.com/iphone.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSLog(@"URL = %@",url);
[request setValidatesSecureCertificate:NO];
[request setRequestMethod:@"POST"];
[request setPostValue:@"user1" forKey:@"user"];
[request setPostValue:@"admin" forKey:@"pass"];
[request setDelegate:self];
[request startAsynchronous];
NSString *response = [NSString stringWithContentsOfFile:
[request downloadDestinationPath] encoding:[request responseEncoding] error:nil];
}
- (void)requestFinished:(ASIHTTPRequest *)request {
NSLog(@"Response %d ==> %@", request.responseStatusCode, [request responseString]);
[activityIndicator stopAnimating];
activityIndicator.hidden = YES;
}
【问题讨论】:
标签: iphone objective-c xcode post asihttprequest