Re: windowDidLoad not getting called

2015-03-19 Thread dangerwillrobinsondanger


 On 2015/03/20, at 6:59, Sean McBride s...@rogue-research.com wrote:
 
 On Thu, 19 Mar 2015 21:21:30 +, Quincey Morris said:
 
 ― Never, ever use “visible at launch” on any window that has a window
 controller.
 
 That'd be a nice thing to assert() in my window controllers... but I just 
 don't see any getter for it... :(
 
 Cheers,
 ___
 
  
That would be a nice assertion especially in the newish convenience methods for 
sheets and popovers where people invariably miss that check box the first go 
round. 
___

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

Runtime message on Yosemite seems spurious?

2015-03-19 Thread Graham Cox
Several of my apps are writing this to the console on Yosemite:

Layout still needs update after calling -[NSScrollView layout].  NSScrollView 
or one of its superclasses may have overridden -layout without calling super. 
Or, something may have dirtied layout in the middle of updating it.  Both are 
programming errors in Cocoa Autolayout.  The former is pretty likely to arise 
if some pre-Cocoa Autolayout class had a method called layout, but it should be 
fixed.

I'm not subclassing NSScrollView and none of these apps use autolayout as such 
- they use the legacy struts-and-springs though I understand they are 
translated to autolayout in the modern OS. Can I safely ignore this, as it 
seems ot be a spurious message, or is it really trying to tell me something 
important?

--Graham





___

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: Runtime message on Yosemite seems spurious?

2015-03-19 Thread John Brownie

On 20/03/2015 8:29, Graham Cox wrote:

Several of my apps are writing this to the console on Yosemite:

Layout still needs update after calling -[NSScrollView layout].  NSScrollView or 
one of its superclasses may have overridden -layout without calling super. Or, something 
may have dirtied layout in the middle of updating it.  Both are programming errors in 
Cocoa Autolayout.  The former is pretty likely to arise if some pre-Cocoa Autolayout 
class had a method called layout, but it should be fixed.

I'm not subclassing NSScrollView and none of these apps use autolayout as such 
- they use the legacy struts-and-springs though I understand they are 
translated to autolayout in the modern OS. Can I safely ignore this, as it 
seems ot be a spurious message, or is it really trying to tell me something 
important?


I see the same thing. My research suggested that you can ignore it, and 
it's probably somewhere in Apple's code.


John
--
John Brownie, john_brow...@sil.org or j.brow...@sil.org.pg
Summer Institute of Linguistics  | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
___

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

windowDidLoad not getting called

2015-03-19 Thread Dave
Hi,

I have a Window Controller (LTWWindowControllerX) that loads a window from a 
NIB file. I have a class called “LTWWindowX” (it inherits from NSWindow) which 
is a non-standard window in that it has the appearance of a “Stickies” or “Tool 
Palette”. 

The File’s Owner in the NIB is set to LTWWindowControllerX.

The NIB File also contains LTWWindowX (an NSWindow with the Class set to 
LTWWindowX) and has some views inside it. There are also a couple of IBOutlet 
properties that are hooked to properties in LTWWindowX.


The Window is Initialised with the following code in LTWWindowControllerX:

-(instancetype) initWithWindowKind:(NSString*) theWindowKind
{
NSString*   myNIBName;

myNIBName = @LTWWindowX;
self = [super initWithWindowNibName:myNIBName];
if (self == nil)
return nil;

return self;
}

Also in LTWWindowControllerX I have the windowDidLoad defined:

-(void) windowDidLoad 
{
NSLog(@***windowDidLoad***);
[super windowDidLoad];
}
——

The Window Controller is instantiated with this code:

myWindowController = [[LTWWindowControllerX alloc] initWithWindowKind:@];
[myWindowController loadWindow];


windowDidLoad doesn’t get called and the “window” property of 
LTWWindowControllerX doesn’t get set.

I’m wondering why and if I need to something “special” in order to make this 
work?

I based this code on the Core Data Stickies sample.

Any help would be greatly appreciated.
All the Best
Dave



___

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: windowDidLoad not getting called

2015-03-19 Thread Bill Cheeseman

 On Mar 19, 2015, at 2:34 PM, Ken Thomases k...@codeweavers.com wrote:
 
 To force the window controller to load the window, request its window 
 property value or call -showWindow: on it (if you want to show the window).

Or set Visible at Launch in the window controller's nib file, at least if you 
don't have to attach a sheet to it or do other things with it before it is 
shown. It really means visible when the nib file loads.

-- 

Bill Cheeseman - b...@cheeseman.name

___

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: windowDidLoad not getting called

2015-03-19 Thread Ken Thomases
On Mar 19, 2015, at 2:49 PM, Bill Cheeseman wjcheese...@gmail.com wrote:

 On Mar 19, 2015, at 2:34 PM, Ken Thomases k...@codeweavers.com wrote:
 
 To force the window controller to load the window, request its window 
 property value or call -showWindow: on it (if you want to show the window).
 
 Or set Visible at Launch in the window controller's nib file, at least if 
 you don't have to attach a sheet to it or do other things with it before it 
 is shown. It really means visible when the nib file loads.

That doesn't help with getting the window controller's -windowDidLoad method 
called.  In fact, that setting almost never helps with anything and, in my 
opinion, should generally be off.  Turning it on just takes control away from 
the window controller.

-Ken


___

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: windowDidLoad not getting called

2015-03-19 Thread Michael Babin

 On Mar 19, 2015, at 1:24 PM, Dave d...@looktowindward.com wrote:
 
 The Window Controller is instantiated with this code:
 
 myWindowController = [[LTWWindowControllerX alloc] initWithWindowKind:@];
 [myWindowController loadWindow];
 
 
 windowDidLoad doesn’t get called and the “window” property of 
 LTWWindowControllerX doesn’t get set.
 
 I’m wondering why and if I need to something “special” in order to make this 
 work?

From 
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/#//apple_ref/occ/instm/NSWindowController/loadWindow

 You should never directly invoke this method. Instead, invoke window 
 https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/index.html#//apple_ref/occ/instm/NSWindowController/window
  so the windowDidLoad 
 https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/index.html#//apple_ref/occ/instm/NSWindowController/windowDidLoad
  and windowWillLoad 
 https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/index.html#//apple_ref/occ/instm/NSWindowController/windowWillLoad
  methods are invoked.

___

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: windowDidLoad not getting called

2015-03-19 Thread Ken Thomases
On Mar 19, 2015, at 1:24 PM, Dave d...@looktowindward.com wrote:

 The Window Controller is instantiated with this code:
 
 myWindowController = [[LTWWindowControllerX alloc] initWithWindowKind:@];
 [myWindowController loadWindow];

You shouldn't call -loadWindow.  -loadWindow is an override point.  See the 
docs for that method.

To force the window controller to load the window, request its window 
property value or call -showWindow: on it (if you want to show the window).


 windowDidLoad doesn’t get called and the “window” property of 
 LTWWindowControllerX doesn’t get set.
 
 I’m wondering why and if I need to something “special” in order to make this 
 work?

Probably a result of your calling -loadWindow, but also make sure you've 
connected the window controller's window outlet to the window in the NIB.

Regards,
Ken


___

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: windowDidLoad not getting called

2015-03-19 Thread Dave
I fixed it, it was calling loadWindow directly, I won’t let that one bite me 
again!



 On 19 Mar 2015, at 19:49, Bill Cheeseman wjcheese...@gmail.com wrote:
 
 
 On Mar 19, 2015, at 2:34 PM, Ken Thomases k...@codeweavers.com wrote:
 
 To force the window controller to load the window, request its window 
 property value or call -showWindow: on it (if you want to show the window).
 
 Or set Visible at Launch in the window controller's nib file, at least if 
 you don't have to attach a sheet to it or do other things with it before it 
 is shown. It really means visible when the nib file loads.


___

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: windowDidLoad not getting called

2015-03-19 Thread Quincey Morris
On Mar 19, 2015, at 13:39 , Bill Cheeseman wjcheese...@gmail.com wrote:
 
 On Mar 19, 2015, at 3:54 PM, Ken Thomases k...@codeweavers.com 
 mailto:k...@codeweavers.com wrote:
 
 That doesn't help with getting the window controller's -windowDidLoad method 
 called.  In fact, that setting almost never helps with anything and, in my 
 opinion, should generally be off.  Turning it on just takes control away 
 from the window controller.

 I believe you're mistaken when you say that the Visible at Launch setting 
 doesn't result in a call to -windowDidLoad.

I believe he was saying it wouldn’t help with the OP’s problem, not that 
windowDidLoad doesn’t happen in that case.

 As far as I'm aware, the only thing that distinguishes the Visible at Launch 
 setting from all of the other Interface Builder settings is that it got a bit 
 of a bad name way back at the beginning because people misunderstood its 
 (admittedly misleading) wording.

I’m 100% with Ken on this issue. The setting is far more horrible than you 
suggest. If you are creating the window’s window controller in code, the window 
controller won’t exist when the window is created (!). Aside from that, a 
visible-at-launch window may end up created before the app’s supporting 
machinery expects it (for example, there may be relevant properties whose value 
isn’t known until later), and this can cause strange and hard-to-debug behavior.

I’d put it this way:

— Never, ever use “visible at launch” on any window that has a window 
controller.

— Don’t bother with “visible at launch” on a window without a window 
controller. It’s not worth the saving of 1 line of code to show the window.



___

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: windowDidLoad not getting called

2015-03-19 Thread Bill Cheeseman

 On Mar 19, 2015, at 3:54 PM, Ken Thomases k...@codeweavers.com wrote:
 
 That doesn't help with getting the window controller's -windowDidLoad method 
 called.  In fact, that setting almost never helps with anything and, in my 
 opinion, should generally be off.  Turning it on just takes control away from 
 the window controller.

Doesn't everything in a nib file take control away from the file's owner? 
That's the point of a nib file. It's true that you can do programmatically most 
or all of what a nib file does using its checkboxes, but why would you want to 
punish yourself like that? -- unless, of course, you need unusually fine 
control over details that the nib file doesn't handle.

I believe you're mistaken when you say that the Visible at Launch setting 
doesn't result in a call to -windowDidLoad. I'm using it now in a rewrite of my 
UI Browser product, and it triggers -windowDidLoad exactly as I expected. I 
don't see anything in my code that would trigger it. When I turn off the nib 
setting the window does not appear at all, let alone call -windowDidLoad. I've 
been following the Visible at Launch story since at least 2002, and I don't 
recall ever hearing a suggestion that it doesn't trigger -windowDidLoad.

As far as I'm aware, the only thing that distinguishes the Visible at Launch 
setting from all of the other Interface Builder settings is that it got a bit 
of a bad name way back at the beginning because people misunderstood its 
(admittedly misleading) wording. It does not make a window visible when the 
application launches, except by coincidence if you happen to load the nib file 
then. That led a lot of early users to believe that the setting was broken. Its 
real meaning was eventually explained in an Interface Builder or Xcode tooltip 
on the setting, maybe 6 or 7 years ago. (In trying to read the tooltip now, in 
Xcode 6.2, I see that there is no tooltip for this setting, although there is a 
tooltip for all the settings above and below it. Now that is really wierd!)

-- 

Bill Cheeseman - b...@cheeseman.name

___

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: windowDidLoad not getting called

2015-03-19 Thread Ken Thomases
On Mar 19, 2015, at 3:39 PM, Bill Cheeseman wjcheese...@gmail.com wrote:

 I believe you're mistaken when you say that the Visible at Launch setting 
 doesn't result in a call to -windowDidLoad. I'm using it now in a rewrite of 
 my UI Browser product, and it triggers -windowDidLoad exactly as I expected.

A window controller doesn't load its NIB unless and until something requests 
its window.  That — the loading of the NIB — is what triggers the 
-windowDidLoad call.  It is called whether or not the window is marked Visible 
at Launch.

Marking the window Visible at Launch obviously can't trigger the loading of the 
NIB, since it's a setting that's stored in the NIB.

 I don't see anything in my code that would trigger it.

Whatever is in your code that's making the window controller load its window is 
what's triggering the call it -windowDidLoad.  This is all clearly documented 
in the NSWindowController class reference.


 When I turn off the nib setting the window does not appear at all, let alone 
 call -windowDidLoad.

I can believe that the window does not appear because you evidently don't call 
-showWindow: on the controller or request its window and invoke 
-makeKeyAndOrderFront: on that.

Frankly, I don't believe you that -windowDidLoad is not called.  I never set 
Visible at Launch on my windows (and turn it off it if it was set by default) 
and rely on -windowDidLoad being called.  And it is.

 I've been following the Visible at Launch story since at least 2002, and I 
 don't recall ever hearing a suggestion that it doesn't trigger -windowDidLoad.

Visible at Launch simply has nothing to do, one way or another, with whether 
-windowDidLoad gets called.  Since Dave was calling -loadWindow rather than 
-window or -showWindow:, -windowDidLoad was not getting called.  You suggested 
that setting Visible at Launch would change this.  It does not.

I was not suggesting that setting Visible at Launch would break things or cause 
-windowDidLoad to not be called.  It just wouldn't address the problem being 
discussed.

Regards,
Ken


___

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: windowDidLoad not getting called

2015-03-19 Thread Sean McBride
On Thu, 19 Mar 2015 21:21:30 +, Quincey Morris said:

— Never, ever use “visible at launch” on any window that has a window
controller.

That'd be a nice thing to assert() in my window controllers... but I just don't 
see any getter for it... :(

Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada

___

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