dimanche 1 mars 2015

Solution for if else and NSString statement

What NSString do I put for return? The answer I am looking for is 1 cheese OR 2 cheeses



- (NSString *) numberOfCheesesStringWithCheeseCount:(NSUInteger)cheeseCount {
if (cheeseCount == 1) {
/* WORK HERE, ASSUMING THERE IS 1 CHEESE */
NSString *phrase = [NSString stringWithFormat:@"%ld", (long)cheeseCount];
NSLog(@"%@ cheese", phrase);
} else {
/* WORK HERE, ASSUMING THERE ARE 2+ CHEESES */
NSString *phrase2 = [NSString stringWithFormat:@"%ld", (long)cheeseCount];
NSLog(@"%@ cheeses", phrase2);
}

/*

(You will learn more about if/else statements in the next checkpoint.)
*/

return ;
}

Aucun commentaire:

Enregistrer un commentaire