这是一个简单的问题,但我在谷歌和stackoverflow上搜索,但我找不到一个例子。
我在Account.h中编写枚举并定义一个方法,将此枚举用作参数:
typedef NS_ENUM(NSUInteger, httpMethod){
GET = 0,
POST,
PUT,
DELETE
};
//method definition
-(void) location:(httpMethod)httpMethod withLocation:(NSString *)location;
在其他类实现中,我称之为
// I do not know how to pass the enum as parameter
[self.myAccount location:Account.httpMethod.PUT withLocation:string];
答案 0 :(得分:1)
您只需使用枚举值:
[self.myAccount location:PUT withLocation:string];