English 中文(简体)
我如何从可可服务器下载数据(不触及)?
原标题:How can I download data from a server in cocoa (not touch)?

Like it s written in the title, How can I download data from a server in my Cocoa Application? So far I looked for, I found this.

最佳回答

ASIHTTPRequest 计算机和麦克风工程

问题回答

如果你不再同时下载大量物品,并再次提出简单的全球培训要求,最容易的方法就是向全球的一个问题发出同步要求:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]];
  NSURLResponse* response = nil;
  NSError* error = nil;
  NSData* result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
  // There will be response data in response now, like the http status code
  // etc. You should check this information to make sure you didn t get a 404
  // or some other http status error
  if( result ) {
    // you have a good result, do something with it like create a new object or
    // pass it to a method on this object, etc.
    dispatch_async(dispatch_get_main_queue(), ^{
      [self doSomethingWithResponseData:result];
    });
  } else {
    // You got an error making the connection, so handle it
    NSLog(@"Error making connection: %@", error);
  }
});

** 说明:这一样本代码使用全球疫苗,因此只能从Snow Leopard(10.6)或更糟。 如果你需要瞄准“ Leopard”或“猛虎组织”,那么你可以使用已派遣的read光挑选器,但不能像在网上。





相关问题
How to upload and download file from a server using C#

I am developing a webpage in that the user can download their Resume for Edit. So I have a link to download the article. I use the following code for download. DataTable dt = user.getUserDetails(2); ...

Detecting PDF Download

I have recently added functionality for generating pdf reports to a web application. However the reports can be quite large and take some time to show the pdf download dialog. I want to show a spinner ...

Writing file to users giving sporadic error in IE

I have a very interesting issue with only specific IE implementations. I have an ASPX page that is used to write files down to the user, as part of the process the page uses the following code to ...

PHP - List of Excel files to download from Intranet Site?

I have a intranet site running PHP 5 that needs to list a folder containing only Excel files. Ideally the user needs to be able to input some search criteria (ie date) and the files would be filtered ...

Determine total size of SVN directory/trunk

Is there a way to count/calculate the total size of a svn directory if you were to checkout a revision? I have limited internet downloads so I need to know how big something is before I go and ...

Scala and html: download an image (*.jpg, etc) to Hard drive

I ve got a Scala program that downloads and parses html. I got the links to the image files form the html, Now I need to transfer those images to my hard drive. I m wondering what the best Scala ...

Downloading file with wxHTTP?

Im really stumped. Im using the wxHTTP class in wxWidgets to try and download two files. The first request succeeds but the second one fails when wxHTTP->GetInputStream is called. Between downloads, ...

热门标签