开发者

iphone execute php url

Beginner question - I have a full URL (in an NSString variable "temp") which I want the application to execute in the background once the user finishes a flow in my iPhone app. I'm having a bit of a problem getting anything to work.

Basically I need to (1) execute the php URL and (2) capture the response and display it back to the user.

Any help is greatly apprecia开发者_如何学Goted!

Thanks


This has been discussed before. Here is a good tutorial web requests

In essence, you need NSURLConnection.


This answer hold all the clues :)

Object-c/iOS :How to use ASynchronous to get a data from URL?


In brief, something like the following. The keys being:

  1. have the url of the content you want
  2. use dataWithContentsOfURL to get the actual byes
  3. create a file
  4. save the image bytes

    If (![fileManager fileExistsAtPath:[destinationAddress stringByAppendingPathComponent:filename]])
    {
      NSError** error;
      NSData* imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:srcAddress] options:NSDataReadingMapped error:error];
      if (imageData != NULL)
     {
        BOOL fileCreated = [fileManager createFileAtPath:destinationAddress contents:imageData attributes:nil];
    
      }
    

    }

Also, use NSURLConnection, if you want to download off the main UI thread (good idea)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜