How to store enum values in a NSMutableArray

前端 未结 6 1194
故里飘歌
故里飘歌 2021-02-06 22:58

My problem is since an enum in objective-c essentially is an int value, I am not able to store it in a NSMutableArray. Apparently NSMutableArray won\'t

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 23:20

    A modern answer might look like:

    NSMutableArray *list = 
     [NSMutableArray arrayWithArray:@[@(green), @(red), @(blue)]];
    

    and:

    MyColors theGreenColor = ((NSInteger*)list[0]).intValue;
    

提交回复
热议问题