1

I have a URL link like "http://mobile/testing.php?action=2, when i have this link on my IE browser, it will redirect the link to "http://mobile/myimage.jpeg". It directed to my database server folder name, where my the file I stored called myimage.jpeg.

I am wondering I how can I can put "http://mobile/testing.php?action=2", establish the NSURL connection and let the Xcode learn this path "http://mobile/myimage.jpeg" so that I can extract the image.jpeg and store it into a list where this list can reflect all the files I had in my database.

Anyone can help? would there be any NSURL reference I can use? I did checkup on the pathomponent, but I don know how can I implement it.

2
  • Xcode is just an IDE. You are referring to Objective-C as language and Cocoa-Touch as API. Please change your question accordingly. Commented Feb 25, 2011 at 17:30
  • This also has nothing to do with MySQL. Commented Feb 25, 2011 at 17:37

1 Answer 1

2

If you want to know where it actually gets redirected to, then you'll need to use an asynchronous NSURLConnection and implement the -[<NSURLConnectionDelegate> connection:didReceiveResponse:] delegate method.

The NSURLResponse object passed to that method will actually be an NSHTTPURLResponse, which means you can:

  1. Ask it for its -statusCode. If the code is a redirection code, then you know your original request was redirected, at which point you can...
  2. Ask it for its -URL. This is the NSURL to which your original request was redirected. From here, you can get its -lastPathComponent to extract the "myimage.jpeg" bit.

If I've totally misunderstood your question, then you can probably just extract the -path from your starting URL and get the -lastPathComponent from that.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes. I got it. I simply used: NSHTTPRespone *myresponse; NSLog(@"%@", myresponse.URL.lastlastcomponent); and I am able to achieve my lastPathComponent name. Thank for the help. :) cheer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.