Created
June 22, 2011 04:51
-
-
Save aaronpearce/1039523 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSString *)avatarCreate:(NSString *)username:(int)num { | |
NSArray *extensions = [NSArray arrayWithObjects:@".gif", @".gif", @".jpg", @".png", nil]; | |
int x = 3; | |
int y = 2; | |
int z = 15; | |
int cachebust = (num >> y) & z; | |
int tnum = num & x; | |
NSString *extension = [extensions objectAtIndex:tnum]; | |
[extension retain]; | |
if([extension isEqualToString:@""]) { | |
extension = @".gif"; | |
} | |
NSString *userurl; | |
if (tnum) { | |
userurl = [NSString stringWithFormat:@"http://a.deviantart.com/avatars/%@/%@/%@%@", [username substringWithRange:NSMakeRange(0, 1)], [username substringWithRange:NSMakeRange(1, 1)], username, extension]; | |
userurl = [userurl lowercaseString]; | |
} else { | |
userurl = [NSString stringWithFormat:@"http://a.deviantart.com/avatars/default.gif"]; | |
} | |
return [NSString stringWithFormat:@"<img src='%@' title='%@' />", userurl, username]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment