Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (NSString*) russianDeclensionForNum:(NSInteger)num one:(NSString*)one two:(NSString*)two five:(NSString*)five {
- return [NSString russianDeclensionForStr:[NSString stringWithFormat:@"%d", num] one:one two:two five:five];
- }
- + (NSString*) russianDeclensionForStr:(NSString*)str one:(NSString*)one two:(NSString*)two five:(NSString*)five {
- NSString *res = nil;
- if ([str hasSuffix:@"1"] && ![str hasSuffix:@"11"]) {
- res = [NSString stringWithFormat:@"%@ %@", str, one];
- } else if([str hasSuffix:@"11"]
- || [str hasSuffix:@"12"]
- || [str hasSuffix:@"13"]
- || [str hasSuffix:@"14"]) {
- res = [NSString stringWithFormat:@"%@ %@", str, five];
- } else if ([str hasSuffix:@"2"] || [str hasSuffix:@"3"] || [str hasSuffix:@"4"]) {
- res = [NSString stringWithFormat:@"%@ %@", str, two];
- } else if ([str hasSuffix:@"0"]
- || [str hasSuffix:@"5"]
- || [str hasSuffix:@"6"]
- || [str hasSuffix:@"7"]
- || [str hasSuffix:@"8"]
- || [str hasSuffix:@"9"]) {
- res = [NSString stringWithFormat:@"%@ %@", str, five];
- } else {
- res = str;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement