Lovely Lovely - 1 year ago 87
Objective-C Question

How enum can be used as string

I have CurrentType as enum in a class like following:

typedef enum {
login = 0,


Now In another ViewController,I want to use this CurrentType as parameter like as follows:

-(void)getLoginUserDetails:(NSData *)response :(CurrentType)service{

But when I write the following in method body


it gives error

How can I use this CurrentType as parameter ???

Answer Source

Concerning your subject: Enums in (Objective-)C are of an integral type like intor long. You can't assign or cast enums to strings directly, but rather have to implement your own conversion function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download