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 
> <cocoa-dev@lists.apple.com> wrote:
> 
> 
>> On Sep 4, 2021, at 10:27 AM, Gabriel Zachmann via Cocoa-dev 
>> <cocoa-dev@lists.apple.com> 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 <NSTextViewDelegate, CALayerDelegate, 
>> 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

Reply via email to