Swift: Trying to use ViewController(). to access object
Swift: Trying to use ViewController(). to access object
- Subject: Swift: Trying to use ViewController(). to access object
- From: "Eric E. Dolecki" <email@hidden>
- Date: Mon, 19 Oct 2015 18:12:47 +0000
I have been using NSNotificationCenter to affect objects in other classes
to good effect. However, is it possible to do something like this:
*ViewController().someObject.hidden = true*
When I compile and run, I get a EXC_BAD_INSTRUCTION at that line.
*fatal error: unexpectedly found nil while unwrapping an Optional value. *
I know it exists in the ViewController scope before my line is called. I
get autocomplete in Xcode for the object too.
I can't import the ViewController in Swift. Is there a simple trick to get
this to work to avoid using NSNotificationCenter in many places? I can
still do that but the ViewController().
Thanks,
Eric
_______________________________________________
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