Lovely Lovely - 26 days ago 11
Objective-C Question

How enum can be used as string

I have CurrentType as enum in a class like following:

typedef enum {
login = 0,
Details,
SendImages,
UpdateDetails,

}CurrentType;


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

service==UpdateDetails


it gives error

How can I use this CurrentType as parameter ???

Answer

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.

Comments