Skip to content

Instantly share code, notes, and snippets.

@davidyeiser
Last active December 26, 2015 14:19
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 davidyeiser/7165148 to your computer and use it in GitHub Desktop.
Save davidyeiser/7165148 to your computer and use it in GitHub Desktop.
My quick and easy way to distinguish singular from plural when it comes to weather alerts.
// "alerts" is the array that contains the weather alerts
int weatherAlertsCount = alerts.count;
NSString *weatherAlertLabelMain = @"";
NSString *weatherAlertLabelMinor = @"";
if (weatherAlertsCount > 1) {
weatherAlertLabelMain = [NSString stringWithFormat:@"%d Weather Alerts", weatherAlertsCount];
}
else {
weatherAlertLabelMain = [NSString stringWithFormat:@"%d Weather Alert", weatherAlertsCount];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment