Abwesenheitsnachricht: Re: Accessing a property of a view via its controller doesn't work
Thank you for your e-mail. I will be back in the office on Monday, 13.09.2021. Your e-mail will not be forwarded. For urgent matters please contact our general office, telephone +49 6182 9626-0 or i...@cgs-oris.com. Kind regards, Herman Keuchel Head of R -- CGS Publishing Technologies International GmbH Email herman.keuc...@cgs-oris.com | Web www.cgs-oris.com Address Kettelerstr. 24 | D-63512 Hainburg | Germany Phone +49 6182 9626-0 | Fax +49 6182 9626-99 Commercial register Offenbach, HRB no. 21495 Managing directors Bernd Rückert, Andreas Kämmerer, Christoph Thommessen ___ 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
Re: Accessing a property of a view via its controller doesn't work
> > I asked earlier, but I’ll ask again: why are you doing this? NSView already > has a `window` property that provides its window. I agree, I guess, I should just remove this ivar. smime.p7s Description: S/MIME cryptographic signature ___ 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
Re: Accessing a property of a view via its controller doesn't work
> On Sep 6, 2021, at 2:14 PM, Gabriel Zachmann via Cocoa-dev > wrote: > > I had assigned the window to an ivar window_ in viewWillMoveToWindow: > > - (void) viewWillMoveToWindow: (NSWindow *) newWindow > { >window_ = newWindow; I asked earlier, but I’ll ask again: why are you doing this? NSView already has a `window` property that provides its window. b ___ 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
Re: Accessing a property of a view via its controller doesn't work
> > Forgot an @synthesize? We haven’t needed to do that since Xcode 4.2. > > Do you know why you needed to do that? It seems pretty much like an edge > case. > Good question. I had assigned the window to an ivar window_ in viewWillMoveToWindow: - (void) viewWillMoveToWindow: (NSWindow *) newWindow { window_ = newWindow; This ivar is declared in MyView.h and as a property @property (readwrite) NSWindow * window_; Well, some of my code is pretty old smime.p7s Description: S/MIME cryptographic signature ___ 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
Re: Accessing a property of a view via its controller doesn't work
> On Sep 6, 2021, at 4:03 PM, Gabriel Zachmann via Cocoa-dev > wrote: > > Mystery solved - it was, of course, a stupid bug on my part. > > Just in case somebody else stumbles across this thread: I had forgotten a > @synthesize in the .m file. > (Xcode emits a warning about this, but I had overlooked it, due to several > other warnings always being there.) > > Sorry for bothering you all. > Forgot an @synthesize? We haven’t needed to do that since Xcode 4.2. Do you know why you needed to do that? It seems pretty much like an edge case. Glad it’s working. Thanks, Alex Zavatone > > >> On 4. Sep 2021, at 20:06, Ben Kennedy wrote: >> >> >>> On Sep 4, 2021, at 10:27 AM, Gabriel Zachmann via Cocoa-dev >>> wrote: >>> >>> I access the window of a view by two different ways, in the controller and >>> in the view, resp., and in the controller, I always get a nil pointer. >>> >>> In my app, I have a subclass of NSView, MyView, declared like this: >>> >>> @interface MyView : NSView >> CAAnimationDelegate> >>> { >>> NSWindow * window_; >>> ... >>> } >>> @property (readwrite) NSWindow * window_; >> >> What’s the purpose of this? NSView already has a `window` property that >> returns its parent window. Why not just use that? >> >> -ben >> >> Sent from my iPhone > > ___ > > 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/zav%40mac.com > > This email sent to z...@mac.com ___ 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
Re: Accessing a property of a view via its controller doesn't work
Mystery solved - it was, of course, a stupid bug on my part. Just in case somebody else stumbles across this thread: I had forgotten a @synthesize in the .m file. (Xcode emits a warning about this, but I had overlooked it, due to several other warnings always being there.) Sorry for bothering you all. > On 4. Sep 2021, at 20:06, Ben Kennedy wrote: > > >> On Sep 4, 2021, at 10:27 AM, Gabriel Zachmann via Cocoa-dev >> wrote: >> >> I access the window of a view by two different ways, in the controller and >> in the view, resp., and in the controller, I always get a nil pointer. >> >> In my app, I have a subclass of NSView, MyView, declared like this: >> >> @interface MyView : NSView > CAAnimationDelegate> >> { >> NSWindow * window_; >> ... >> } >> @property (readwrite) NSWindow * window_; > > What’s the purpose of this? NSView already has a `window` property that > returns its parent window. Why not just use that? > > -ben > > Sent from my iPhone smime.p7s Description: S/MIME cryptographic signature ___ 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
Re: Accessing a property of a view via its controller doesn't work
Perhaps a more germane question might be, are you sure that the view controller has a relationship with any window? It is not necessary, as I understand, for a view to exist in a window. A view controller can load a view without placing it into a window, and therefore viewWillMoveToWindow: will not be called, and I suspect the “window” property would be set. Breakpoints are your friend. Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" > On Sep 4, 2021, at 12:06 PM, Ben Kennedy via Cocoa-dev > wrote: > > >> On Sep 4, 2021, at 10:27 AM, Gabriel Zachmann via Cocoa-dev >> wrote: >> >> I access the window of a view by two different ways, in the controller and >> in the view, resp., and in the controller, I always get a nil pointer. >> >> In my app, I have a subclass of NSView, MyView, declared like this: >> >> @interface MyView : NSView > CAAnimationDelegate> >> { >> NSWindow * window_; >> ... >> } >> @property (readwrite) NSWindow * window_; > > What’s the purpose of this? NSView already has a `window` property that > returns its parent window. Why not just use that? > > -ben > > Sent from my iPhone > ___ > > 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/cocoa-dev%40esoteritech.com > > This email sent to cocoa-...@esoteritech.com ___ 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
Re: Accessing a property of a view via its controller doesn't work
> I access the window of a view by two different ways, in the controller and in > the view, resp., and in the controller, I always get a nil pointer. Have you verified that the view you’re accessing in the controller is the same instance as the one that works? ___ 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
Re: Accessing a property of a view via its controller doesn't work
> On Sep 4, 2021, at 10:27 AM, Gabriel Zachmann via Cocoa-dev > wrote: > > I access the window of a view by two different ways, in the controller and > in the view, resp., and in the controller, I always get a nil pointer. > > In my app, I have a subclass of NSView, MyView, declared like this: > > @interface MyView : NSView CAAnimationDelegate> > { >NSWindow * window_; >... > } > @property (readwrite) NSWindow * window_; What’s the purpose of this? NSView already has a `window` property that returns its parent window. Why not just use that? -ben Sent from my iPhone ___ 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
Re: Accessing a property of a view via its controller doesn't work
I don’t know why this is happening, but I’ll often populate a variable if I know it from another class and can’t find it from another. By that, I mean if you know the window in the class that opens the preferences, get it and set it in the MasterViewController. > On Sep 4, 2021, at 12:26 PM, Gabriel Zachmann via Cocoa-dev > wrote: > > I access the window of a view by two different ways, in the controller and in > the view, resp., and in the controller, I always get a nil pointer. > > > In my app, I have a subclass of NSView, MyView, declared like this: > > @interface MyView : NSView CAAnimationDelegate> > { >NSWindow * window_; >... > } > @property (readwrite) NSWindow * window_; > > > In one of MyView's instance methods, I save the window like this: > > - (void) viewWillMoveToWindow: (NSWindow *) newWindow > { >window_ = newWindow; >... > > > Also in MyView, I have this line to interrogate the styleMask at some point > later during runtime: > >if ( [window_ styleMask] & NSWindowStyleMaskFullScreen ) >... > > This works fine, window_ has a proper value (as a pointer), and styleMask > returns values as expected. > > > However, I have pretty much the same line in my MasterViewController, which > does not work. > > > In the MasterViewController, I create an instance of MyView like this: > > - (void) viewDidLoad > { >[super viewDidLoad]; >myview_ = [[MyView alloc] initWithFrame: self.view.frame isPreview: NO ]; >[self.view addSubview: myview_]; >... > > > Then, in MasterViewController's showPreferences:, I have this code: > > - (IBAction) showPreferences: (id) sender > { >if ( [myview_.window_ styleMask] & NSWindowStyleMaskFullScreen ) > ... > > > Here, myview_.window_ is always 0. > > > How could that be? > > Puzzled, Gabriel. > > > ___ > > 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/zav%40mac.com > > This email sent to z...@mac.com ___ 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
Accessing a property of a view via its controller doesn't work
I access the window of a view by two different ways, in the controller and in the view, resp., and in the controller, I always get a nil pointer. In my app, I have a subclass of NSView, MyView, declared like this: @interface MyView : NSView { NSWindow * window_; ... } @property (readwrite) NSWindow * window_; In one of MyView's instance methods, I save the window like this: - (void) viewWillMoveToWindow: (NSWindow *) newWindow { window_ = newWindow; ... Also in MyView, I have this line to interrogate the styleMask at some point later during runtime: if ( [window_ styleMask] & NSWindowStyleMaskFullScreen ) ... This works fine, window_ has a proper value (as a pointer), and styleMask returns values as expected. However, I have pretty much the same line in my MasterViewController, which does not work. In the MasterViewController, I create an instance of MyView like this: - (void) viewDidLoad { [super viewDidLoad]; myview_ = [[MyView alloc] initWithFrame: self.view.frame isPreview: NO ]; [self.view addSubview: myview_]; ... Then, in MasterViewController's showPreferences:, I have this code: - (IBAction) showPreferences: (id) sender { if ( [myview_.window_ styleMask] & NSWindowStyleMaskFullScreen ) ... Here, myview_.window_ is always 0. How could that be? Puzzled, Gabriel. smime.p7s Description: S/MIME cryptographic signature ___ 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