【发布时间】:2011-01-13 19:13:36
【问题描述】:
我在我的实现文件中声明了一个枚举,如下所示,并在我的接口中声明了一个该类型的变量作为 PlayerState thePlayerState;并在我的方法中使用了该变量。但我收到错误,指出它未声明。如何在我的方法中正确声明和使用 PlayerState 类型的变量?:
在.m文件中
@implementation View1Controller
typedef enum playerStateTypes
{
PLAYER_OFF,
PLAYER_PLAYING,
PLAYER_PAUSED
} PlayerState;
在 .h 文件中:
@interface View1Controller : UIViewController {
PlayerState thePlayerState;
在 .m 文件中的某些方法中:
-(void)doSomethin{
thePlayerState = PLAYER_OFF;
}
【问题讨论】:
-
现在枚举的类型是 thePlayerState。 playerStateTypes 变成了什么?
-
有关 NS_ENUM 及其最新现代语法的信息,请参阅 Mattt Thompson 的帖子NS_ENUM & NS_OPTIONS。
标签: iphone objective-c c