Yan Li
Yan Li

Reputation: 1819

Objective-C pass enum as parameter in other class?

This is simple question but I have search on Google and stackoverflow but I cant found an example.

I write enum in Account.h and define a method use this enum as parameter:

typedef NS_ENUM(NSUInteger, httpMethod){
    GET = 0,
    POST,
    PUT,
    DELETE
};

//method definition
-(void) location:(httpMethod)httpMethod withLocation:(NSString *)location;

In other class implementation, I call this method

// I do not know how to pass the enum as parameter
[self.myAccount location:Account.httpMethod.PUT withLocation:string];

Upvotes: 1

Views: 1445

Answers (1)

Marco Pace
Marco Pace

Reputation: 3870

You can simply use the enum value:

[self.myAccount location:PUT withLocation:string];

Upvotes: 2

Related Questions