Skip to content

Instantly share code, notes, and snippets.

@BenBarahona
Created August 22, 2013 18:18
Show Gist options
  • Save BenBarahona/6310846 to your computer and use it in GitHub Desktop.
Save BenBarahona/6310846 to your computer and use it in GitHub Desktop.
- (NSString *)constructHashTagForAppCopy:(NSString *)appCopy
{
NSRange hashRange = [appCopy rangeOfString:@"#hashtag#" options:NSCaseInsensitiveSearch];
if(hashRange.location != NSNotFound)
{
NSString *hashCopy = [self.channel objectForKey:@"hashtag"];
if(!hashCopy)
{
hashCopy = @"";
}
else
{
hashCopy = [NSString stringWithFormat:@"%@", [self.channel objectForKey:@"hashtag"]];
// Double checking if hashcopy is correct
if(![[hashCopy substringToIndex:1] isEqualToString:@"#"])
{
hashCopy = [NSString stringWithFormat:@"#%@", hashCopy];
}
}
appCopy = [appCopy stringByReplacingCharactersInRange:hashRange withString:hashCopy];
}
else
{
return appCopy;
}
return appCopy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment