3

Is it good programming practice to define all (IBAction) methods associated with a NSViewController's .xib within a class extension?

gcamp
  • 14,622
  • 4
  • 54
  • 85
tgma4stuff
  • 31
  • 2

2 Answers2

1

There's no reason to declare the IBAction in the class extension, if the intent is merely to make the IBAction method private. Just add the implementation of the action method in the controller @implementation.

ybakos
  • 8,152
  • 7
  • 46
  • 74
1

Everything that's in the class extension is private to your class.

So the real question here is your IBAction here is private to your view controller or not. If that's something used internally, like the press of a button to activate a function inside your view controller, then yes, put it in your class extension.

gcamp
  • 14,622
  • 4
  • 54
  • 85
  • 2
    Doesn't putting an IBAction in a class extension hide it from IB connections, because it's in the implementation file instead of the header file? – Jon Reid Sep 07 '11 at 03:29
  • 1
    Very cool! But not until the latest and greatest is out of beta :) – Jon Reid Sep 07 '11 at 16:30