Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (NSString *)afterNumberTextWithNumber:(NSNumber *)number
  2.                                 oneText:(NSString *)text1
  3.                                 fewText:(NSString *)text2
  4.                                 lotText:(NSString *)text3
  5. {
  6.     int withoutHundred     = number.intValue % 100;
  7.     int lastDigit          = withoutHundred % 10;
  8.     NSString *text         = text3;
  9.     NSArray *exceptNumbers = @[@11, @12, @13, @14];
  10.    
  11.     if (lastDigit == 1 && ![exceptNumbers containsObject:number]) {
  12.         text = text1;
  13.     }
  14.     if (lastDigit > 1 && lastDigit < 5 && ![exceptNumbers containsObject:number]) {
  15.         text = text2;
  16.     }
  17.    
  18.     return [NSString stringWithFormat:@"%@ %@", number, text];
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement