0
votes

I'm trying to change dynamically my xib File owner using the dependancy injection framework "Objection". If you don't know Objection just understand that I just want to change dynamically my xib File owner.

Let me take an exemple.
When I start my App I bind the allocation of the class "MainMenuBlue" to the class "MainMenu"

[self bindBlock:^(JSObjectionInjector *context) {
        return [[MainMenuBlue alloc] init] autorelease];
} toClass:[MainMenu class]];

Based on my configuration I sometimes bind it to "MainMenuRed" or "MainMenuYellow" etc...

The problem obviously is that my xib file owner is "MainMenu" so it create a "MainMenu".
Strange isn't it? :-)
Do you know an elegante way to link the xib to the good controller ? Without copying MainMenu.xib to MainMenuBlue.xib, MainMenuRed.xib, MainMenuYellow.xib

I believe this will not be possible using xib file so I will have to keep away from interface builder...

Important:
This is just an example to illustrate my need. Of course in reality I don't only change a background color.

EDIT:
Thanks to Jasper Blues I find out. Actually I created a problem who is not really one.
Based on my configuration I just need to do:

[[MainMenuBlue alloc] initWithNibName:@"MainMenu" bundle:nil];

or

[[MainMenuRed alloc] initWithNibName:@"MainMenu" bundle:nil];



Martin Magakian

1

1 Answers

1
votes

It doesn't matter what class is specified in the file's owner as long as it responds to the same messages as the class provided at runtime. Ie the file's owner just serves as an interface to wire up your connections.

When you do your binding be sure to use initWithNibName:bundle: