Re: Swift: Trying to use ViewController(). to access object
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 12:38:24 -0700
> On Oct 19, 2015, at 11:12 AM, Eric E. Dolecki <email@hidden> wrote:
>
> I have been using NSNotificationCenter to affect objects in other classes
> to good effect.
I don’t understand … that class is used to register notification observers and to post notifications. What do you mean by “affect”?
> *ViewController().someObject.hidden = true*
>
> When I compile and run, I get a EXC_BAD_INSTRUCTION at that line.
That line doesn’t make sense to me. `ViewController()` will create a new ViewController instance, but you’re never assigning it to a variable or property, so it’s probably going to be dealloced after this line returns. So this doesn’t really do anything.
> I know it exists in the ViewController scope before my line is called.
Again, I’m not sure what that means. Especially since the ViewController object doesn’t exist before that line is called.
—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