• 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: sending data to a view not yet displayed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sending data to a view not yet displayed


  • Subject: Re: sending data to a view not yet displayed
  • From: Dave Carrigan <email@hidden>
  • Date: Sat, 15 Jan 2011 14:50:54 -0800

On Jan 15, 2011, at 1:49 PM, Shane wrote:

> I am creating views which are being prepared for view swapping in the
> init method of my apps main controller. So the view controllers exists
> and each view controller's init method calls initWithNibName:.
>
> My problem is that, if I swap views by selecting a view so that it is
> displayed, when I load my data, data is being added to my outlets and
> shown on my view.
>
> But if I do not select the view by clicking on my interface (so the
> view has not yet been displayed since I started the app), when I load
> my data, then the data that I send to my outlets does not get shown in
> the view when I do select it at a later time.
>
> So I guess my question is, how do I make sure my view is able to
> receive the data I want sent to it before it is ever displayed. I hope
> that makes sense.

If this is iOS, -initWithNibName doesn't actually load the nib immediately, so the outlets won't be connected until such time as the nib is loaded, which doesn't happen until something tries to access the view. Instead, you should initialize your outlets' data in the -viewDidLoad method. While you could force the nib to be loaded by accessing the view property, in low-memory situations, the view controller will unload the view behind your back, so I would recommend doing your initialization in -viewDidLoad.

_______________________________________________

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

  • Follow-Ups:
    • Re: sending data to a view not yet displayed
      • From: Shane <email@hidden>
References: 
 >sending data to a view not yet displayed (From: Shane <email@hidden>)

  • Prev by Date: Re: sending data to a view not yet displayed
  • Next by Date: Re: sending data to a view not yet displayed
  • Previous by thread: Re: sending data to a view not yet displayed
  • Next by thread: Re: sending data to a view not yet displayed
  • Index(es):
    • Date
    • Thread