Objective C - 枚举的 getter 和 setter 属性
我是 Objective-C 的新手。我有一个枚举,如下:
typedef enum _XLBadgeManagedType {
XLInboxManagedMethod = 0,
XLDeveloperManagedMethod = 1
} XLBadgeManagedType ;
我想要它的 getter 和 setter 方法,这样如果发生某些情况,我将 XLInboxManagedMethod 设置为 1。我将如何去做呢?
I am a complete newbie at Objective-C. I have an enum as follows:
typedef enum _XLBadgeManagedType {
XLInboxManagedMethod = 0,
XLDeveloperManagedMethod = 1
} XLBadgeManagedType ;
I want to have getter and setter methods for it, such that if something happens, I set XLInboxManagedMethod
to 1. How would I go about doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的代码只是定义一个枚举类型。它是一个静态的、编译时常量,不会改变。您可以通过声明枚举的实例,然后将其更改为您定义的常量值之一来使用枚举。如果您的枚举如下所示:
那么您的属性可能如下所示:
并且其用途可能如下所示:
Your code is just defining an enum type. It's a static, compile-time constant that is not changed. You use enums by declaring an instance of one, then changing it to one of the constant values you defined. If your enum looks like:
Then your property could look like:
And its use may look like:
您不更改枚举的值。他们保持原样。
You do not change the values of enums. They stay as they are.
它们是符号常量。你无法改变它。
They are symbolic constants. You can not change it.