gpt4 book ai didi

iphone - 将枚举值保存到字典中

转载 作者:IT王子 更新时间:2023-10-29 08:07:26 25 4
gpt4 key购买 nike

如何将枚举值保存到字典中?

当我尝试以下操作时

enum someEnum
{
field0 = 0,
field1 = 1,
field2 = 2,
};

enum someEnum someEnumObject;

然后我尝试使用

将其保存到字典中

[NSDictionary dictionaryWithObjectsAndKeys:]

someEnumObject, @"enum", 

我明白了

warning: Semantic Issue: Incompatible integer to pointer conversion sending 'enum behaviour' to parameter of type 'id'

最佳答案

使用下面的方法将其保存到字典中,

[NSNumber numberWithInt:enumValue], @"enum",

你可以检索它,

enumValue = [[dictionary valueForKey:@"enum"] intValue];

关于iphone - 将枚举值保存到字典中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6663686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com