开发者

How to create global enum

开发者 https://www.devze.com 2023-01-14 11:39 出处:网络
How to access enum through all classes. Let me explain: enum { BottomBackButtonNav = 0, BottomNextButtonNav,

How to access enum through all classes. Let me explain:

enum
{
   BottomBackButtonNav = 0,
   BottomNextButtonNav,
   BottomSliderIncreaseNav,
   BottomSliderDcreaseNav,
   PageSwipeLeftNav,
   PageSwipeRightNav,
   NavFromThumbnailView,
   NavFromTOCView,
} NavigationType;

This enum is defined in my MainViewController's head开发者_如何学Pythoner and want to use it to all my views. How to do this, please guide.

Regards.


You can define it in an header file (.h) and import it in each module you need


You can also create a header file that holds all your enums and then import this header file in your projects .pch file (usually located in your Supporting Files folder).


This Prefix header uses the contents of this file and includes them on every source file. So it pretty much imports whatever headers that are set in the #ifdef __OBJC__ section to every file during compile time.

0

精彩评论

暂无评论...
验证码 换一张
取 消