有没有办法使用Xcode将bit.ly转换为完整的url?
问题描述:
我想知道这是否真的有可能,因为我的问题已经用尽了解决方案。bit.ly短链接正在毁了我的一天。下面的代码是我试图拉开,但这不适用于bit.ly链接。它总是检测bit.ly链接,然后谷歌重定向链接。有没有办法使用Xcode将bit.ly转换为完整的url?
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if (inType == UIWebViewNavigationTypeLinkClicked) {
if ([[inRequest.URL absoluteString] rangeOfString:@"google"].location==NSNotFound){
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
}
return YES;
}
答
继承人获得任何短网址到原来的URL的快捷,方便和线程安全的方式
链接:https://github.com/emotality/ATURLExpander
例子:
[[ATURLExpander urlEngine] expandURL:@"http://bit.ly/1dNVPAW" withBlock:^(NSError *error, NSString *longURL) {
if (error) {
NSLog(@"ATURLExpander ERROR : '%@'", error);
} else {
NSLog(@"ATURLExpander URL : '%@'", longUrl);
}
}];
这将是可取的为您[编辑您以前的未回复的帖子](http://*.com/questions/15371404/xcode-nslog-weird-hitch)关于同样的问题比重新发布。 – 2013-03-13 00:32:02