user4951
user4951

Reputation: 33090

Do IBOutlets have to be public?

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?

Upvotes: 1

Views: 530

Answers (2)

jrturton
jrturton

Reputation: 119242

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.

Upvotes: 6

Sebastian Flückiger
Sebastian Flückiger

Reputation: 5555

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?

Upvotes: 1

Related Questions