21
将Objective-C Typedef转换为其等效字符串
假设我在.h文件中声明了typedef,如下所示: typedef enum { JSON, XML, Atom, RSS } FormatType; 我想构建一个将typedef的数值转换为字符串的函数。例如,如果消息[self toString:JSON]已发送;它将返回“ JSON”。 该函数将如下所示: -(NSString *) toString:(FormatType)formatType { //need help here return []; } 顺便说一句,如果我尝试这种语法 [self toString:FormatType.JSON]; 将typedef值传递给方法,我得到一个错误。我想念什么?
141
c
objective-c
enums
typedef