| Start |
|---|
| typedef enum declaration in Objective-C A enum declares a set of ordered values - the typedef just adds a handy name to this. The 1st element is 0 etc. |
| Defining an enum Enums are defined by the following the syntax above. You also can set your own raw-values to the enumeration types. You can also specify on the first value and all the following will use it with increment: Variables of this enum can be created by |
| Converting C++ std::vector Many C++ libraries use enums and return/receive data using vectors that contain enums. As C enums are not Objective-C objects, Objective-C collections cannot be used directly with C enums. The example below deals with this by using a combination of an NSArray and generics and a wrapper object for the array. This way, the collection can be explicit about the data type and there is no worry about possible memory leaks with C arrays Objective-C objects are used. Here is the C enum & Objective-C equivalent object: And here is a possible use of it in Objective-C++ (the resulting NSArray can be used in Objective-C only files as no C++ is used). If this kind of solution is to be used on multiple enums, the creation of the EnumObj (declaration & implementation) can be done using a macro (to create a template like solution). Syntax
|
Read Article
https://develop.horje.com/learn/1434/reference