On Feb 5, 2016, at 2:39 PM, Jean-Daniel Dupas wrote: Le 5 févr. 2016 à 19:28, Alex Zavatone < email@hidden> a écrit :
I seem to recall back circa last century in Xcode 3.1.3 that when a view controller was instantiated that part of the loading/bootstrapping of the view controller was that it would automatically look for an XIB of the same name as the viewController and load that on the Mac OS.
Strange your recall that. It is documented as working since 10.10 (which did not exists at the time Xcode 3.1.3 was the standard):
I've been using this for like 4+ years. I could be confusing things a tad, but I've got projects from 2011 that do this.
From -[NSViewController loadView] header documentation.
Prior to 10.10, -loadView would not have well defined behavior if [self nibName] returned nil. On 10.10 and later, if nibName is nil, NSViewController will automatically try to load a nib with the same name as the classname. This allows a convenience of doing [[MyViewController alloc] init] (which has a nil nibName) and having it automatically load a nib with the name "MyViewController".
On iOS, I recall that it would look for a xib of the same name as the view controller for the iPhone and then it would look for an xib with the same name of the view controller and "~iPhone.xib" and it would automatically look for an xib that was the same name of the view controller + "~iPad.xib".
Now, I can't seem to find any of the docs that mentioned this and I'm trying to verify this functionality and where it is called from by stepping through the debugger at the view controller's initialization.
This is where I need some help.
I think the magic append in -loadView, so you should break on the loadView method.
Already tried to, but I guess setting a breakpoint on the method in the header doesn't do anything.
The LLDB tip from you and Jim does work though. Thanks
I was expecting something in the nib loading category though. I still haven't found out which method is being called that loads the external xibs.
What I'm trying to find is more clear definition on what happens on iOS in a storyboard scene that has a custom view controller with its top level view missing.
If you have a view controller called StuffVC and that has these files,
Stuff.h Stuff.m Stuff.xib (with the view outlet wired to Stuff)
and you then assign StuffVC as the class for a storyboard scene's view controller class, but then go all crazy and delete the top level view, when that view controller appears, it loads the XIB.
That's actually pretty awesome, because it makes handling building your UI a whole lot more manageable, because 1 XIB is so much easier to set up elements on than some massive storyboard with all the other scenes you aren't immediately interested in.
Essentially, you use the storyboard and the XIBs are essentially linked.
What this does is allows the storyboard to exist as a skeleton and each XIB is automatically used when needed and is much easier to configure when laying out the UI.
I'm trying to find the clear path of what does the loading of the XIB and that it's actually standard behaviour that is supported and intended by Apple.
(I have a tiny sample iOS project that does this if anyone wants to see.)
So far I've seen the nib loading extensions to NSBundle but those don't seem like they are being called, are there any other areas that would make sense to investigate?
Thanks guys.
Alex Zavatone |