views:

23

answers:

1

When a class is customized, by using its outlet , you cant access its method. Is there any better solution to access the method of a customized class? without posting notification?

To be more specific, sometimes when a Controller Class having outlets of other classes, could access the method of the corresponding classes. But the reverse is not always true. Why is this behavior?

A: 

You don't put a class in an outlet, you put an instance there. That's because a nib never contains classes, only instances.

And you most certainly can send messages to objects in outlet variables. The view, where by “view” I mean the object that's in a controller's outlet, can't talk back to the controller only if the view does not have an outlet of its own that's connected to the controller. So, give the view an outlet to the controller.

Note that the nib system treats outlets as properties, so you'll want the controller's outlet to be retaining (unless the view is a subview of another view, or the content view of a window) and the view's outlet to be non-retaining (assigning). If both properties are retaining, you'll have a retain cycle.

Peter Hosey