Skip to content

Instantly share code, notes, and snippets.

@seivan
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seivan/8793649 to your computer and use it in GitHub Desktop.
Save seivan/8793649 to your computer and use it in GitHub Desktop.
Because it's 23:30 and I'm tired as fuck.
-(NSString *)platformsAsOxfordComma; {
NSArray * platforms = (NSArray *)self.platforms;
return [platforms SH_reduceValue:@"".mutableCopy withBlock:^id(NSMutableString * memo, NSString * obj) {
if(platforms.lastObject == obj) {
if(platforms.count > 1) [memo appendString:NSLocalizedString(@"AND", nil)]; // Do other languages even work like this?
[memo appendString:obj];
}
else {
[memo appendString:obj];
[memo appendString:@", "];
}
return memo;
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment