如何使用ASIHttp请求解析数据?

时间:2009-09-25 00:09:47

标签: iphone

我正在使用webservices.I我正在从iphone发送请求并获取数据。我正在使用http请求。但我想使用ASIhttprequest以便它如何可能?

1 个答案:

答案 0 :(得分:2)

您应该查看ASIS3Request类,了解有关如何继承ASIHTTPRequest并在请求完成之前或之后执行您自己的任务的详细信息。你自己的子类看起来像这样:

@interface MyFancySubclass : ASIHTTPRequest {}
@end

@implementation MyFancySubclass

- (void) main {
  // Perform pre-request initialisation here
  [super main];
}

- (void) requestFinished {
  // Parse [self responseString] or [self responseData] here
  [super requestFinished];
}

- (void) failWithError:(NSError*)theError {
  // Handle errors here
  [super failWithError:theError];
}

@end

如果将MyFancySubclass个实例添加到ASINetworkQueue,则解析将在主线程中完成。

相关问题