Get the last redirected url in iOS 5?

后端 未结 2 668
天涯浪人
天涯浪人 2021-01-22 17:39

Can someone please post the simplest of working code that can get the last redirected url(nth) when I GET request a url?

I know I need to use asynchronous requests but

2条回答
  •  佛祖请我去吃肉
    2021-01-22 18:32

    Please read Handling Redirects and Other Request Changes in the documentation. Briefly, you'll want to a) provide a delegate for your connection, and b) implement the method connection:willSendRequest:redirectResponse: in said delegate. I don't understand exactly what you're trying to do in your question -- do you just want the data from URL to which your connection is redirected, or do you want to see the redirected request? Either way, implementing the method above should help. Your delegate will be able to see the redirected request, and returning it unchanged should cause the connection to load the new URL.

提交回复
热议问题