Reputation: 3582
I have an enum
defined like this:
typedef enum dataTypes{
LOW,
MEDIUM,
HIGH,
MAX_DATA_TYPE
} dataTypeEnum;
I'd like to be able to instantiate an NSArray
of NSNumber
s like so:
NSArray * numsToUse = @[@LOW, @MEDIUM];
This is not compiling. Any insights? Do I have to go with the clunkier [NSNumber numberWithInt:]
for each of these or is there a way around this? (I have considered and rejected #define
statements for a number of reasons).
Upvotes: 2
Views: 198
Reputation: 299265
You just need to use the expression syntax:
NSArray * numsToUse = @[@(LOW), @(MEDIUM)];
Upvotes: 5