我的问题是因为objective-c中的枚举本质上是一个int值,我无法将其存储在一个NSMutableArray.显然NSMutableArray不会采用像int这样的任何c数据类型.
有没有什么常见的方法来实现这一目标?
typedef enum
{
green,
blue,
red
} MyColors;
NSMutableArray *list = [[NSMutableArray alloc] initWithObjects:
green,
blue,
red,
nil];
//Get enum value back out
MyColors greenColor = [list objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)