#import <Foundation/Foundation.h>
NSString *getRandomItemFromMenuList(NSArray *menuList) {
int max = (int)[menuList count];
NSException *e = [NSException
exceptionWithName:@"EmptyMenuListException"
reason:@"*** The list has no food!"
int randomIndex = arc4random_uniform(max);
return menuList[randomIndex];
int main(int argc, const char * argv[]) {
NSString *foodItem = getRandomItemFromMenuList(@[]);
NSLog(@"The selected food is: %@", foodItem);
} @catch(NSException *theException) {
if (theException.name == @"EmptyMenuListException") {
NSLog(@"Caught an EmptyMenuListException");
NSLog(@"Ignored a %@ exception", theException);