• 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: Swift: Trying to use ViewController(). to access object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift: Trying to use ViewController(). to access object


  • Subject: Re: Swift: Trying to use ViewController(). to access object
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 19 Oct 2015 16:36:03 -0700

> On Oct 19, 2015, at 1:53 PM, Eric E. Dolecki <email@hidden> wrote:
>
> I am asking if there is a way to call a method or set a property on an ViewController object from another class.

Sure, you just need a reference to it.

> let foo = ViewController()
> foo.object.hidden = true
> Something like that, but which works.

It sounds like the actual question is “how do I get a reference to my ViewController?” The answer depends on the context. What’s the method that needs to do this? Show us the entire method (and what class it’s in.)

Is it Cocoa programming in general that’s giving you problems, or is this something you know how to do in Objective-C but just aren’t sure in Swift?

—Jens
_______________________________________________

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: 
 >Swift: Trying to use ViewController(). to access object (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Swift: Trying to use ViewController(). to access object (From: Jens Alfke <email@hidden>)
 >Re: Swift: Trying to use ViewController(). to access object (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: Debugging Faux Delegate calls
  • Next by Date: Re: NSButton with NSTexturedRoundedBezelStyle outside of NSToolbar
  • Previous by thread: Re: Swift: Trying to use ViewController(). to access object
  • Next by thread: titleForHeaderInSection wrong section count.
  • Index(es):
    • Date
    • Thread