On Mon, 26 Jul 2010 11:35:20 -0700, Jay Reynolds Freeman
<jay_reynolds_free...@mac.com> said:
>Investigation revealed, however, that though the desired
>instance of my subclassed UIViewController was in fact getting
>loaded and some of its code is running, the IBOutlets that
>I hooked up from the File's Owner in the second xib file,
>to the desired objects in that file, were *not* getting
>initialized at load- and run-time; they all were ending
>up nulls.  There is supposed to be a mechanism that tracks
>down these links and makes them right in the real instance
>of the subclassed UIViewController that is created at
>load-time, but that mechanism was not working for me.

What do you mean "there is supposed to be a mechanism"? Do you mean the
normal nib-loading KVC-based setting out outlets? If so, there is not
"supposed" to be a mechanism; there *is* a mechanism. If this was not
working you need to figure out why. There is no point substituting an
unknown for another unknown. There are many reasons why outlets come out as
nil at load time; a common one is that you didn't really draw the outlet in
the nib; another is that you have a setXXX method that is not the accessor
for the corresponding ivar.

Also, at this point I have to wonder - is the controller's view actually
getting added to the window? That's an outlet from the file's owners in that
second nib, after all. If that's nil, then no view is added to the window.
If the view is not present in the window, the controller is not going to get
asked about rotating it.

>After looking at much documentation and checking lots of
>things (spellings right, class types declared properly,
>IBOutlets all set up as properties with @property and
>@synthesize, NIB Name correctly declared in the IB
>inspector, et cetera), I simply added a specific load
>of the relevant xib file in the code for my app's
>"application:didFinishLaunchingWithOptions:", just
>before the "addView" wherein the call to
>"shouldAutorotateToInterfaceOrientation" should occur.
>
>(The relevant code is
>
>    [[NSBundle mainBundle] loadNibNamed:@"Pixie_Scheme_IIIViewController"
owner:viewController options:nil];
>
>and I have wrapped it with NSLogs to be sure it runs, checked
>it for null return, and so on.)
>
>That code alone was sufficient to cause the null IBObject
>links that I mentioned earlier, to be resolved properly at
>run time.  I have not had to do anything with the NSArray
>of top-level objects that it returns, to make that happen.

No, but the nib's owner is still responsible for doing memory management on
the top-level objects in the nib. Does it have accessors (probably
synthesized) for all its outlets, and do they all use (probably through a
property declaration) a retain policy?

You're just being so coy about your code. Why don't you just *show* the
revelant parts of the code? Or at least, why not continue doing what I
suggested before - make an essentially blank app and prove to yourself that
this basic mechanism works there, and then ask yourself how what you're
doing differs from that?

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to