Tono Nam
Tono Nam

Reputation: 36060

get IBOutlets from xib file

In my nib file I have several controls that I placed with xcode. Is there a way I can find how many outlets there are in the nib file. since I placed all the objects in the default view of the nib file maybe I can get the child of the default view and those will be the IBOutlets. I plan on latter adding functionality to those IBOUtlets.

In short I am trying to create a connection with code.... Thats cause I have so many objects in every nib file. I am creating an app that is like a power point presentation and I have several slides..

Upvotes: 0

Views: 311

Answers (2)

Mundi
Mundi

Reputation: 80271

SubclassedViewController *controller = [[SubclassedViewController alloc] 
    initWithNibName:@"SubclassedViewController" bundle:nil];

// actually, [[... alloc] init]; does the same

for (UIView *aView in [controller.view subviews]) {
    // do stuff
}

You could identify the Views with tags, an integer properties that you can attach to any UIView (also in Interface Builder).

Upvotes: 3

cpjolicoeur
cpjolicoeur

Reputation: 13106

IBOutlets arent' actually anything. That is just syntactical sugar to allow Interface Builder introspection into your code files to match up variable names.

Anyways, you can just look through all the subviews of your view in code if you need to. Not ideal, but i think this is what you are asking for.

Upvotes: 3

Related Questions