Displaying phrases containing numbers
I’m in the middle of writing an app in Swift which requires an alert to appear which says something like “10 questions entered”. But of course some times it should say “1 question entered”. The traditional approach to the question/questions situation is to either test for the number and create a string accordingly or to use the rather tacky “question(s). As I needed similar phrases in a number of places, I decided that the best approach was to create a function. Although the app I’m writing is for OSX, the functions described below should work in iOS as well.