假设我在.h文件中声明了一个typedef:
typedef enum {
JSON,
XML,
Atom,
RSS
} FormatType;
Run Code Online (Sandbox Code Playgroud)
我想构建一个将typedef的数值转换为字符串的函数.例如,如果邮件[self toString:JSON]已发送; 它会返回'JSON'.
该函数看起来像这样:
-(NSString *) toString:(FormatType)formatType {
//need help here
return [];
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句,如果我尝试这种语法
[self toString:FormatType.JSON];
Run Code Online (Sandbox Code Playgroud)
要将typedef值传递给方法,我收到一个错误.我错过了什么?