开发者

Help with typedef enum

This is my first time using a typedef enum and I n开发者_运维百科eed some help setting it. Here is some of my code:

typedef enum {
user,
vip,
admin
} status;
@property (nonatomic, assign) status status;

When I call this

[self setStatus:vip];

It works fine. But when I call it again, the app crashes with nothing in the console. I call it again, but with a different status, such as

[self setStatus:user];

What should I do to fix my code? Thanks in advance

Also, status is synthesized in the .m.


Instead of nonatomic & assign... make it readwrite since typedef is technically represented by numbers.


try this code instead

typedef enum {
    user,
    vip,
    admin
} Status

@implementation thisClass {
    Status status;
}

@property (nonatomic, readwrite) Status status;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜