9

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 header and want to use it to all my views. How to do this, please guide.

Regards.

Sam Dolan
  • 31,966
  • 10
  • 88
  • 84
TechBee
  • 1,897
  • 4
  • 22
  • 46

2 Answers2

18

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

rano
  • 5,616
  • 4
  • 40
  • 66
10

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.

John Riselvato
  • 12,854
  • 5
  • 62
  • 89
  • I like the ease of implementation it sounds this brings, but it sounds like this would also heavily impact compile time and app size? Is that the case? If it's just compile time I can deal, but I'd prefer not to take an implementation shortcut if it's going to significantly affect the size of my app. – Jake T. Oct 25 '17 at 16:39