YES and NO are BOOL, which is not an Objective-C class. Foundation containers can only store Objective-C objects.
You need to wrap them in NSNumber, for example:
NSNumber* yesObj = [NSNumber numberWithBool:YES]; NSMutableArray* arr = [[NSMutableArray alloc] initWithObjects: yesObj, yesObj, yesObj, yesObj, nil]; NSLog(@"%d", [[arr objectAtIndex:1] boolValue]);
The reason it accepts NSString is because NSString is a kind of Objective-C class.
source share