在我的应用程序中,我使用以下代码从我的服务器检索数据:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
NSLog(@"Want to redeem: %@", textField.text);
NSURL *url = [NSURL URLWithString:@"http://localhost:8888/iPhone/page.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
// Hide keyword
[textField resignFirstResponder];
// Clear text field
textView.text = @"";
// Start hud
return TRUE;
}
现在我该怎么做才能在$array
函数中获取requestFinished
的内容
答案 0 :(得分:0)
首先,我必须指向ASIHTTPRequest文档:http://allseeing-i.com/ASIHTTPRequest/How-to-use。但我认为你想要做的很简单,就像这样:
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSString *responseString = [request responseString];
}
我希望你觉得这很有用,否则我建议你改一下你的问题。
答案 1 :(得分:0)
我认为您需要将php输出格式化为可以解析为数组的格式... JSON或XML,然后使用类似SBJSON或NSXMLParser的东西(我建议使用前者)。也许结果是产品信息(例如)所以你的php会输出:
[{"id":123,"price":5.99,"itemName":"toy car"},{"id":456","price":0.99,"itemName":"hot coffee"}]
然后,你会
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSArray *responseArray = [[request responseString] JSONValue];
//do something with the array
}