0

I have two objects: NavButton, visible on each ViewController and a particular ViewController. NavButton should know, which kind of ViewController is asking for it and hide unneeded buttons. I consider implementing this as passing an enum from ViewController to NavButton.
I have two questions on this:
1. Where should I declare enum? 2. How to make enum visible in all of the ViewControllers, so, each VC could access NavButton's property as: self.navButton.kind = bigButton;

Richard Topchii
  • 7,075
  • 8
  • 48
  • 115

1 Answers1

1

Just use the C header template + the nsenum macro expansion and voila!

//
//  Header.h
//  Test
//
//  Created by Yours Truly on 8/7/14.
//  Copyright (c) 2014 Adam Christopher Smith. All rights reserved.
//

#ifndef Test_Header_h
#define Test_Header_h

typedef NS_ENUM(NSUInteger, MyEnum) {
    MyEnumValueA,
    MyEnumValueB,
    MyEnumValueC,
};

#endif

If I have a lot of these and they are used by different parts of the app, I tend to stick quite a few into one file (maybe, Types.h) and put that into my pch. Quite acceptable IMO.

Acey
  • 8,048
  • 4
  • 30
  • 46