可以将其他项目添加到现有枚举类型? [英] Possible to add another item to an existing enum type?
问题描述
不知是否有可能增加/另一个项目追加到现有枚举类型(框架的一部分)?
I wonder whether it is possible to add/append another item to an existing enum type (part of a framework)?
事情是这样的:我们有枚举
键入
Something like this: We have the enum
type
typedef enum {
UIModalTransitionStyleCoverVertical = 0,
UIModalTransitionStyleFlipHorizontal,
UIModalTransitionStyleCrossDissolve,
UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;
现在我想追加或添加到这个设置像 UIModalTransitionStyleCoverVerticalFlipped
的项目。
可这样的事情来实现?
Now I want to append or add to this set an item like UIModalTransitionStyleCoverVerticalFlipped
.
Can something like this be accomplished?
推荐答案
您可以强制新元素具有相同类型的枚举,但可以将其在子类中不能延长。
头文件:
You can force new element to have the same type as the enum, but you can't extend it in a subclass. header file:
extern const UIModalTransitionStyle UIModalTransitionStyleCoverVerticalFlipped;
实现文件:
const UIModalTransitionStyle UIModalTransitionStyleCoverVerticalFlipped = 10;
确认给予一定空间的情况下,该框架被扩展,使您不必冲突。这是一个黑客位,但它会摆脱编译器错误和警告。
Make sure to give some space in case the framework is extended, so that you don't have conflicts. This is a bit of a hack, but it will get rid of compiler errors and warnings.
这篇关于可以将其他项目添加到现有枚举类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!