Am 05.06.2010 um 23:14 schrieb Jean-François Brouillet: > Consider the situation where I have a "root" ImageView in IB. > I specify the actual image I want it to hold by just filling/ > selecting which of the existing images are already present in the > project, using the "Image" input box of the Image View Attributes > inspector. > > Then I can just set the titleView outlet of some navigationItem > elsewhere in the same nib file, and voilà, my image is displayed > at runtime exactly where I want I, when I want it. > > But now I create a second nib file for a second controller, and > I really would like to display the same image in the same kind > of setup. > > Problem is: I haven't figured out whether it is possible at all > for nib file#2 to refer to any object inside nib file#1,
No it is not. > hence > I have to either pay the memory cost of a duplicate object in > the second nib file, Yes. as Ken told you, views can have only one superview. > So, I've got the message, thank you, and I'm going to *programatically* share > that view either in the app delegate or the root view controller, whichever > way is cleanest. This will break. See above. And because you will try it you make clear that you did not understand the answer given by Ken. > or forget about nib files entirely and do > the whole wiring by hand with code, which kind of defeats the > purpose of separate nib files in the first place. Why should you have to do that? You just need one titleView in every nib. A simple imageView takes up some bytes in memory. The image itself is shared anyway. You win nothing by trying to reuse that view. > So ... is there a way to refer to NIB1.objA from NIB2.objB ? No. And there never will be, as it is impossible (see Ken’s very good explanation). It _is_ a beginners question and it was answered in detail. > Bonus question: is it possible at all to refer to nib files > (while staying within IB) outside of the main project directory? > I tried variations on ./rsrc/mynib2 or rsrc/mynib2 in the NIB Name > input field to no avail ... They have to be anywhere in the project. Just use the name, as they will be copied to Resources. > I plainly understand that I can spread my NIB files all over the > place (almost :-) if I go the coding route, but I'd rather do > everything I can in IB if that's possible ... Yes, use nibs. Then just add that one image view and be done with it. atze _______________________________________________ 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