• 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: Access object from another view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Access object from another view


  • Subject: Re: Access object from another view
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 21 Sep 2010 12:27:43 -0700

On Sep 21, 2010, at 11:57, Steve Wetzel wrote:

> How do I access and object on one view from another view?  I cannot figure it out.
>
> I have two view controllers and two views.  Lets call them viewController1 and viewController2 and view1 and view2.  ViewController1 loads the second view by:
>
> [self.view addSubview:viewController2.view];
>
> There is a label in view1 that I want to get the value of the text from in the code for viewController2.  How do I do this?

Probably no one can advise you on the *best* way to do this without knowing exactly what you're trying to achieve. (Are there NIB files involved? How is the label initialized in view1? Does the label change during execution in such a way that view2 must be dynamically updated to match view1? Which views and controllers are aware of -- have references to -- the other views and controllers?)

The answer probably involves making the text value of the label a property of viewController1, and propagating it to the other places via bindings, KVO or setting via outlets.


_______________________________________________

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: Access object from another view
      • From: Steve Wetzel <email@hidden>
References: 
 >Access object from another view (From: Steve Wetzel <email@hidden>)

  • Prev by Date: Access object from another view
  • Next by Date: Re: Access object from another view
  • Previous by thread: Access object from another view
  • Next by thread: Re: Access object from another view
  • Index(es):
    • Date
    • Thread