By effect I meant it works as expected. Even when I set a variable to that ViewController, I get the error. I am asking if there is a way to call a method or set a property on an ViewController object from another class.
let foo = ViewController() foo.object.hidden = true Something like that, but which works. On Mon, Oct 19, 2015 at 3:38 PM Jens Alfke <j...@mooseyard.com> wrote: > > On Oct 19, 2015, at 11:12 AM, Eric E. Dolecki <edole...@gmail.com> 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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com