如何使用objective-c& amp;读取网站上的文件xcode

我正在尝试编写一个代码来获取我的服务器(远程)提供的一些信息,例如请求一个url,它将返回解析后将在应用程序中表示的数据。 我已经尝试了2天,现在我用谷歌搜索了我发现了一些不完整的解决方案,但没有什么真的对我有用 我在Xcode和Objective-C中真的很棒 谢谢     
已邀请:
单击Apple提供的URL加载文档。 特别是
Using NSURLConnection
对你来说很有趣。 编辑: 另一个非常好且易于使用的框架是ASIHTTP: 点击 最简单的方法:
- (void)grabURL
{
  NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
  ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
  [request startSynchronous];
  NSError *error = [request error];
  if (!error) {
    NSString *response = [request responseString];
  }
}
异步加载只是稍微复杂一些:
- (void)grabURLInBackground
{
   NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
   ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
   [request setDelegate:self];
   [request startAsynchronous];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
   // Use when fetching text data
   NSString *responseString = [request responseString];

   // Use when fetching binary data
   NSData *responseData = [request responseData];
}

- (void)requestFailed:(ASIHTTPRequest *)request
{
   NSError *error = [request error];
}
    

要回复问题请先登录注册