NSString* HTML = [NSString stringWithContentsOfURL:url usedEncoding:&enc error:&error];
works great, but if there is a redirect I need to know the url of the redirected page.
Any ideas?
Thanks~~
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will probably want to use NSURLConnection and load manually rather than using the stringWithContesOfURL method. Then you can set a URLConnectionDelegate on your connection. When you get redirected, the connection will call this method on your delegate:
The request argument provides the URL that you are being redirected to. You can inspect it and do what you want with it. If you want to allow the redirect to continue then you should return it from your delegate’s method.