views:

507

answers:

2

I have a view in an application. The view contains a UITableView and a UIToolbar, and within the UIToolbar I have UISegmentedControl that is contained within a UIBarButtonItem object.

I can get the segmented control to link to an IBAction event, and it then acts upon a value change, but I cannot see how to add an IBOutlet to this item.

When I try to add this link, the only object that appears to want to accept the outlet link is the tableview. I would expect this to be wanting to go into an outlet on the File's Owner.

What am I missing here?

A: 

Your question is unclear.

If your trying to add an outlet to the segmented control i.e. an outlet that runs from the segmented control to another object, then you have to subclass the segmented control with an added outlet property. An outlet is a pointer to an external object so the class has to allocate memory for the pointer and create a symbol for it.

If your trying to link an outlet from the File Owner to the segmented control but are seeing not seeing the File Owner's outlet property as a choice, then you either (1) have defined the outlet incorrectly in the File Owners class or (2) not set the File Owner to the proper class.

For (1), in your File Owner class you should have something that looks like this:

@property (nonatomic, retain) IBOutlet UISegmentedControl *mySegmentedControl; //best

or

@property id mySegmentedControl; //works but is sloppy unless the flexibility is required

For (2) In interface builder, look in the inspector in the identity panel and check that the proper class is assigned to File Owner.

TechZen
The first sample (1) is correct, but (2) is incorrect. It should be @property id mySegmentedControl; (no *).
Ben Gottlieb
Hah, yes, that always trips me up even after all these years. I just can't defeat the habit with something I know is an object.
TechZen
A: 

Actually, the problem turned out to be that the view was not correctly assigned, and was using an invalid subclass. That was preventing File's Owner from permitting me to see the IBOutlets - which had already been correctly specified in the .h file.

As soon as I corrected the class hierarchy, the problem went away.

Thanks, all y'all, for your assistance.

Redback
You should hit the checkmark next to this answer so the system knows the question has been answered.
TechZen
Yes, I know, but when I went to do it a few days ago, the system would not let me do it then, telling me that I needed to wait a further two days before it would permit me to do so.Now done. Cheers, and thanks for the reminder.
Redback