• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Outlets Not Connected In awakeFromNib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Outlets Not Connected In awakeFromNib


  • Subject: Re: Outlets Not Connected In awakeFromNib
  • From: Andreas Grosam <email@hidden>
  • Date: Thu, 03 Mar 2011 13:27:45 +0100

On Mar 3, 2011, at 12:31 PM, Uli Kusterer wrote:

> On 02.03.2011, at 10:54, Andreas Grosam wrote:
>> I have a very basic custom UIViewController with its own associated nib file. This view controller is the "root view controller" of a Navigation Controller which is itself embedded within a Split View Controller which is defined in another nib - say the main.nib.
>
> tl;dr
>
> But do you have any objects that are part of several NIBs? I.e. a view controller that is instantiated by one NIB, but the view controller has a NIB of its own that it loads in turn? In that case, you'll get -awakeFromNib twice. Once when the containing NIB is instantiated, and a second time after you load the containED NIB.

No, there is just two nib files, the main.nib and the RootViewController.nib.

You can easily create this scenario from a template project in Xcode. For iOS use a Navigation Based Application.

The "main.nib" is defined as follows:

File's Owner   		    	UIApplication
First Responder
App Delegate       		NavigationBasededAppDelegate
Window
Navigation Controller
   Navigation Bar
   Root View Controller 	RootViewController -> Nib Name = "RootViewController.nib"


Note: "Root View Controller" isn't embedded within the main.nib, instead it has its own nib "RootViewController.nib". In order to reference the nib file from within the main nib, the "nib Name" property of the Root View Controller (within the main.nib) is defined and its value is "RootViewController" - which shall be the nib for this object.



In order to create this in a sample, you need to define an outlet in the root view controller, e.g.:

@interface RootViewController ... {
    IBOutlet UIView* testView;
}
@property (nonatomic, retain) IBOutlet UIView* testView;
@end

Then, in IB, add this view and connect the outlet as appropriate.


Then, the "RootViewController.nib" is defined as:

File's Owner       RootViewController
First Responder
Table View
Test View


The RootViewController has an Outlet 'testView' which references "Test View" within the same nib (RootViewController.nib).


When -awakeFromNib is sent to the root view controller, the outlet 'testView' is not connected. The message is sent during *loading the main nib*. The root view controller does not receive another -awakeFromNib message.


Andreas




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Outlets Not Connected In awakeFromNib (From: Andreas Grosam <email@hidden>)
 >Re: Outlets Not Connected In awakeFromNib (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Outlets Not Connected In awakeFromNib
  • Next by Date: Re: Outlets Not Connected In awakeFromNib
  • Previous by thread: Re: Outlets Not Connected In awakeFromNib
  • Next by thread: Re: Outlets Not Connected In awakeFromNib
  • Index(es):
    • Date
    • Thread