Getting Safe[r] Short links in your iOS App

UPDATE: This post has been updated here.

Traditionally known for their bloat ware anti-virus, McAfee has decided to get into the short-URL service with their new beta program of Many security experts have agreed that using URL shortening services is a great way to masquerade malicious sites and to dupe victims into visiting them. McAfee’s new service applies their site reputation scoring to the links you submit. Sites with a “Red” level will be blocked from being displayed and a banner is displayed at the top. For more details about how they rank sites, visit their documentation site: or This is a way to add a little more trust to the links that you share.

McAfee URL Shortener Screen Shot

Now, say you have an iOS app that has Twitter integration of some sort and you want to share shortened links in a more safe manner by using Mcafee’s short-URL service. It’s very simple to do so in code.

//First setup the URLs
NSURL *urlToShorten=[NSURL URLWithString:@""];
NSURL *mcafeeShortener=[NSURL URLWithString:[NSString stringWithFormat:@"", urlToShorten]];

//Get the resulting web page
NSString *mcafeeResults=[NSString stringWithContentsOfURL:mcafeeShortener encoding:NSStringEncodingConversionAllowLossy error:nil];

//Start to parse the result by finding the generated link
NSRange urlRange=[mcafeeResults rangeOfString:@"is mapped to <a href=""];

NSRange spanRange=urlRange;

NSRange urlEndRange=[mcafeeResults rangeOfString:@"">" options:NSLiteralSearch range:spanRange];

/The range of the shortened link is in between the two ranges

NSString *mcafeeShortenedURLString=[mcafeeResults substringWithRange:spanRange];
NSLog(@"MCafee URL: %@", mcafeeShortenedURLString);

No comments yet.

Leave a Reply