1

The outlet from xib?

Is there a way to make it private?

In fact, I am pretty confused with objective-c. Isn't the idea of object oriented presuppose encapsulation?

jrturton
  • 118,105
  • 32
  • 252
  • 268
user4951
  • 32,206
  • 53
  • 172
  • 282

2 Answers2

6

You are right, if outlets are only relevant to the implementation of a class then they should not be "public" (declared in the .h file).

You can declare outlets in a class extension inside the .m file. These will be recognised by interface builder.

In Xcode 4.3, view controller subclasses created from templates have this class extension added automatically for this purpose. Ctrl-dragging into the .m file using the assistant editor will create new outlets.

jrturton
  • 118,105
  • 32
  • 252
  • 268
  • Wow awesome. +1 selected as the answer – user4951 Apr 18 '12 at 02:20
  • I learned through tutorials, and often we are told to drag outlets to the header file. Good to know they can be dragged to the implementation file. – Jim Sep 05 '13 at 05:53
1

it is sort of possible, but not truly :-)

a 'trick' way would be something on the lines of: Tutorial: Encapsulation

and also check out this question, with a great discussion: Why doesn't Objective-C support private methods?

Community
  • 1
  • 1
Sebastian Flückiger
  • 5,525
  • 8
  • 33
  • 69