You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even though Objective-C is a dynamic language, it's basically impossible to get an enum value given its name as an NSString because an Objective-C/C enum is essentially just an integer (whereas in Java, it can easily be done via the reflection API).
But in the context of protobuf, this problem can be solved by having the compiler add an NSDictionary in which the keys are enum names (NSString) and values are enum values. It could add another dictionary to map enums to their names.
The text was updated successfully, but these errors were encountered:
Now in my source code I already have NSString such as @"Timeout" and @"Disconnect", which I would like to convert to a MessageType enum. I.e. @"Timeout" -> MessageTypeTimeout and @"Disconnect" -> MessageTypeDisconnect.
There's no easy way to do that in Objective-C. But since the enum type was generated by the compiler, it would be nice if the compiler also inserted a NSDictionary in the file. For example,
The whole point is to provide a way to inspect every enum type, which is something not possible in Objective-C but doable with the help of protobuf compiler.
Even though Objective-C is a dynamic language, it's basically impossible to get an enum value given its name as an NSString because an Objective-C/C enum is essentially just an integer (whereas in Java, it can easily be done via the reflection API).
But in the context of protobuf, this problem can be solved by having the compiler add an NSDictionary in which the keys are enum names (NSString) and values are enum values. It could add another dictionary to map enums to their names.
The text was updated successfully, but these errors were encountered: