リダイレクトされた URL をコンソールに表示しようとしています。コードのどこかに小さな詳細が欠けている可能性があります。
- (void)viewDidLoad {
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 119, self.view.bounds.size.width, self.view.bounds.size.height - 165)];
webView.backgroundColor = [UIColor whiteColor];
// webView.userInteractionEnabled = NO;
webView.opaque = NO;
[webView loadHTMLString:self.item.description baseURL:[NSURL URLWithString:self.item.link]];
[self.view addSubview:webView];
webView.delegate = self;
}
- (NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *)redirectResponse
{
//Make sure tinyurl is doing the redirection
if([[[redirectResponse URL] host] compare:@"bitly.com"
options:NSCaseInsensitiveSearch] == NSOrderedSame)
{
NSLog(@"Redirect Location: %@", [request URL]);
}
//call [connection cancel]; to cancel the redirect and stop receiving data
//return nil; to cancel redirect but continue receiving data
//return request; will continue the redirection as normal
return request;
}