Re: Opposite of windowDidLoad
> On Jan 12, 2017, at 12:53 PM, Quincey Morris >wrote: > > windowWillClose is an acceptable place to tear down the binding only if (a) > the thing bound, and the thing bound to, still exist, and (b) there is no > chance that the window will be re-opened. Both of those are typically true, > but it does depend on what you’re doing. > > Window dealloc/deinit is also a possible time, but again you need to be sure > that the relevant objects still exist, probably by keeping strong references > to them in the window controller itself (and again it depends on what you’re > doing). The nice thing about windowWillClose for this is that if the binding ends up retaining your window controller somehow, you don’t end up with a retain cycle. Charles ___ 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: Opposite of windowDidLoad
On Jan 12, 2017, at 03:46 , Daryle Walker <dary...@mac.com> wrote: > > I was thinking of adding a Cocoa Binding during my window-controller's > did-load method. But where would the unbinding go? You’re sort of asking the wrong question. The time to bind or unbind is dependent on the thing being bound and the thing being bound to. You must establish the binding after both things have been created, and tear down the binding before either thing is destroyed. Note that windowDidLoad is a place where things like this are often done, because it happens at a time where you know that everything in the window that comes from a NIB file has been loaded and therefore exists. > I see waiting until deinit or implementing NSWindowDelegate and using > windowWillClose. Quibble: you *conform to* NSWindowDelegate (all of its methods are optional, so you can conform to it without implementing anything in it), and you *implement* windowWillClose (or not, since it is optional). windowWillClose is an acceptable place to tear down the binding only if (a) the thing bound, and the thing bound to, still exist, and (b) there is no chance that the window will be re-opened. Both of those are typically true, but it does depend on what you’re doing. Window dealloc/deinit is also a possible time, but again you need to be sure that the relevant objects still exist, probably by keeping strong references to them in the window controller itself (and again it depends on what you’re doing). > Is there a similar access point for view-controllers? Not for tearing down the binding. viewDidLoad is provided for you at the completion of NIB loading, for the same reason as windowDidLoad: because it’s hard otherwise for your code to know when NIB loading is complete without being told. For the opposite action, you can do it at dealloc/deinit as above. ___ 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: Opposite of windowDidLoad
If the window has the same lifespan as the controller, why not dealloc? Otherwise, wherever your closing your window. Sandor > On Jan 12, 2017, at 06:46, Daryle Walkerwrote: > > I was thinking of adding a Cocoa Binding during my window-controller's > did-load method. But where would the unbinding go? I see waiting until deinit > or implementing NSWindowDelegate and using windowWillClose. > > Is there a similar access point for view-controllers? > > 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/admin.szatmari.net%40gmail.com > > This email sent to admin.szatmari@gmail.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
Opposite of windowDidLoad
I was thinking of adding a Cocoa Binding during my window-controller's did-load method. But where would the unbinding go? I see waiting until deinit or implementing NSWindowDelegate and using windowWillClose. Is there a similar access point for view-controllers? 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: windowDidLoad getting called twice?
Hi, I found the problem, it was in the Class above the one where I as looking, very confusing as the debugger is a bit glitchy in this area and wouldn’t let me Step Into/Out of properly….. Thanks for the help, 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 getting called twice?
> On 28 Feb 2016, at 17:55, Keary Suska <cocoa-...@esoteritech.com> wrote: > > >> On Feb 28, 2016, at 8:10 AM, Dave <d...@looktowindward.com> wrote: >> >> the winddowDidLoad method of my Window Controller is getting called twice. >> Is this expected behaviour? The window is the NIB has no views setup in the >> window ContentView, I add them after the window NIB has loaded. I’m guessing >> the second call is when I add subviews to the Content View….. > > As I understand, no. No need to guess—set a break point and know. > I have, it’s getting called twice, and I think I now know why, this is the windowDidLoadMethod -(void) windowDidLoad { LTWWindowBase* myWindow; //[super windowDidLoad]; myWindow = (LTWWindowBase*) self.window; [myWindow initializeWindowWithWindowController:self]; } It’s being called when I access the self.window, which is not surprising because accessing .window the first time triggers the loadWindow methods etc. I guess I can’t access .window from this method? The initializeWindowWithWindowController method adds the initial views to the Content View, is there another method where it is safe to do this? I suppose I could schedule it to run a short time after windowDidLoad has returned? What’s the recommended way of doing this? Thanks for your help. 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 getting called twice?
> On Feb 28, 2016, at 8:10 AM, Davewrote: > > the winddowDidLoad method of my Window Controller is getting called twice. Is > this expected behaviour? The window is the NIB has no views setup in the > window ContentView, I add them after the window NIB has loaded. I’m guessing > the second call is when I add subviews to the Content View….. As I understand, no. No need to guess—set a break point and know. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ 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 getting called twice?
Hi, the winddowDidLoad method of my Window Controller is getting called twice. Is this expected behaviour? The window is the NIB has no views setup in the window ContentView, I add them after the window NIB has loaded. I’m guessing the second call is when I add subviews to the Content View….. 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
On Mar 19, 2015, at 5:29 PM, Ken Thomases k...@codeweavers.com wrote: 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. Yes, I lost my focus when I said that and incorrectly conflated the loading and the showing of the window. My original post to this thread simply stated that the nib file's Visible at Launch setting is an alternative to referencing the window property or calling -showWidow to display the window, and that's what I meant to say. I believe I am right, when the application launch sequence is set up as I set up mine. My launch sequence goes like this: My Info.plist file designates MainMenu as the application's principal nib file. My MainMenu nib file names NSApplication as file's owner, it contains the menu bar and my archived appDelegate object, and it connects appDelegate as NSApplication's delegate. MainMenu.xib does not contain a window object, as Ken has recommended. At launch, MainMenu is loaded as the designated principal nib file, its appDelegate archive is unarchived, and NSApplication calls appDelegate's implementation of the -applicationDidFinishLaunching: delegate method. My implementation of the delgate method then explicitly creates my window controller object and initializes it using -initWithWindowNibName:MainWindow. This is what loads my MainWindow nib file and calls its -windowDidLoad method. When the nib file loads, somebody notices that MainWindow.xib's Visible at Launch setting is set, so it immediately shows the window. My code requires no explicit reference to the window property and no call to -showWindow or -makeKeyAndOrderFront: to make the window appear. The Visible at Launch setting in the MainWindow nib file is sufficient by itself, which is the only point I was trying to make. At least, that's how I understand it works, and I run into no difficulties when I do it this way in my applications. This has been my standard setup for single-window shoebox or library applications for a while now, although it is only more recently that I switched from calling -showWindow explicitly to relying on the Visible at Launch setting on the general principle that it is best to let your nib files do as much as they can unless you need greater control. I should have mentioned in my original post that the Visible at Launch setting would not be sufficient if you use the -initWithWindow: designated initializer, as the OP is doing, because, as Quincey pointed out, that initializer expects you to load the nib file or create the window yourself at some point before you create the window controller. -- 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
On Mar 20, 2015, at 5:21 AM, Ken Thomases k...@codeweavers.com wrote: On Mar 20, 2015, at 3:54 AM, Bill Cheeseman wjcheese...@gmail.com mailto:wjcheese...@gmail.com wrote: My launch sequence goes like this: My Info.plist file designates MainMenu as the application's principal nib file. My MainMenu nib file names NSApplication as file's owner, it contains the menu bar and my archived appDelegate object, and it connects appDelegate as NSApplication's delegate. MainMenu.xib does not contain a window object, as Ken has recommended. At launch, MainMenu is loaded as the designated principal nib file, its appDelegate archive is unarchived, and NSApplication calls appDelegate's implementation of the -applicationDidFinishLaunching: delegate method. My implementation of the delgate method then explicitly creates my window controller object and initializes it using -initWithWindowNibName:MainWindow. This is what loads my MainWindow nib file and calls its -windowDidLoad method. Nope. That's not enough. A window controller does not load the NIB (nor call -windowDidLoad) just because it's been allocated and initialized with a NIB name. Something has to be requesting the window. Yes, you're right. Re-examining my appDelegate code and looking at the backtrace from -windowDidLoad as you suggested, I see that in -applicationDidFinishLaunching:, right after I create and initialize the MainWindowController object, I set an appDelegate window outlet programmatically to mainWindowController.window, where mainWindowController is an instance variable of type MainWindowController, my NSWindowController subclass. So I do reference the MainWindowController object's window property in my code, after all. I had completely forgotten that I did this, because I did it much earlier in the development process to replace the Xcode application template's connection of an appDelegate window object in MainMenu.xib. The template doesn't use a window controller. The window reference didn't stand out when I looked at the code again because I'm still getting used to dot notation now that I'm writing code in Swift. When I comment out my window reference in appDelegate, the -windowDidLoad method is not called and the window does not appear at launch. When I replace the window reference with a call to -showWindow, the -windowDidLoad method is again called and the window appears at launch. I have now unselected the Visible at Launch setting in my MainWindow nib file and gone back to my former practice of calling -showWindow. My apologies for the noise. It's been educational, though -- at least for me. -- 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
On Mar 20, 2015, at 3:54 AM, Bill Cheeseman wjcheese...@gmail.com wrote: My launch sequence goes like this: My Info.plist file designates MainMenu as the application's principal nib file. My MainMenu nib file names NSApplication as file's owner, it contains the menu bar and my archived appDelegate object, and it connects appDelegate as NSApplication's delegate. MainMenu.xib does not contain a window object, as Ken has recommended. At launch, MainMenu is loaded as the designated principal nib file, its appDelegate archive is unarchived, and NSApplication calls appDelegate's implementation of the -applicationDidFinishLaunching: delegate method. My implementation of the delgate method then explicitly creates my window controller object and initializes it using -initWithWindowNibName:MainWindow. This is what loads my MainWindow nib file and calls its -windowDidLoad method. Nope. That's not enough. A window controller does not load the NIB (nor call -windowDidLoad) just because it's been allocated and initialized with a NIB name. Something has to be requesting the window. Again, I ask you to read the docs for NSWindowController, in particular the -window method, and reconcile that with how you think it works. If just initializing the window controller with a NIB name was sufficient to load it, why would that start with If the window has not yet been loaded, this method attempts to load the window’s nib…? When the nib file loads, somebody notices that MainWindow.xib's Visible at Launch setting is set, so it immediately shows the window. My code requires no explicit reference to the window property and no call to -showWindow or -makeKeyAndOrderFront: to make the window appear. It must. The Visible at Launch setting in the MainWindow nib file is sufficient by itself, which is the only point I was trying to make. Visible at Launch is sufficient to make the window show once the NIB has been loaded, but you're missing something that is loading the NIB. Put a breakpoint in -windowDidLoad and look at the stack trace. Or log [NSThread callStackSymbols] in -windowDidLoad. You'll find what's doing it. 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
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
windowDidLoad not getting called
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
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
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
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
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
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
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
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
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
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
-windowdidLoad
What does [super windowDidLoad} accomplish in the subclass implementation of -windowDidLoad and is it necessary? -rags ___ 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
On Feb 5, 2015, at 13:13 , Raglan T. Tiger r...@crusaderrabbit.net wrote: What does [super windowDidLoad} accomplish in the subclass implementation of -windowDidLoad and is it necessary? If “the subclass” is a direct subclass of NSWindowController, then it does what the NSWindowController class reference says it does: The default implementation does nothing.” However, it’s possible you might insert another class between the subclass and the base class in the future, and invoking the ‘super’ method protects you against inadvertently creating a bug when doing so. Also, more or less the same point, it relieves your subclass from knowing exactly what it’s a subclass of. ___ 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: -awakeFromNib vs. -windowDidLoad [Was: devil of a time with an NSImageView]
On Aug 20, 2009, at 10:59 AM, Kyle Sluder wrote: Use -awakeFromNib to do view setup (turning on layer backing, creating caches colors, etc.). Use -windowDidLoad (or - windowControllerDidLoadNib or whatever that NSDocument method is) for setting up inter-view relationships. Hmm ... so would you say to do otherwise is doing it wrong or doing it sub-optimally? I don't recall such guidelines in the documentation, so if I've missed it (or it's been added since I last studied the relevant docs), I would very much appreciate a reference. If not, I think this is a great topic of discussion (ie, a general architectural approach). -- I.S. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -awakeFromNib vs. -windowDidLoad [Was: devil of a time with an NSImageView]
On Aug 20, 2009, at 8:05 AM, I. Savant idiotsavant2...@gmail.com wrote: Hmm ... so would you say to do otherwise is doing it wrong or doing it sub-optimally? No, but if it winds up mattering, that's how it usually shakes out. So I tend to follow that pattern even before it begins to matter. --Kyle Sluder ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -awakeFromNib vs. -windowDidLoad [Was: devil of a time with an NSImageView]
On Aug 20, 2009, at 11:05 AM, I. Savant wrote: On Aug 20, 2009, at 10:59 AM, Kyle Sluder wrote: Use -awakeFromNib to do view setup (turning on layer backing, creating caches colors, etc.). Use -windowDidLoad (or - windowControllerDidLoadNib or whatever that NSDocument method is) for setting up inter-view relationships. Hmm ... so would you say to do otherwise is doing it wrong or doing it sub-optimally? I'm relatively new to NSWindowController, but I think one benefit is avoiding multiple calls to awakeFromNib on the same object when you have objects in a nib which might themselves load nibs. --Andy ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
- windowDidLoad not getting called !
Hi all, I have written an application for which in the about box there is a link to a website. Below is the code for it NSMutableAttributedString *tempCompanyURLString = [[NSMutableAttributedString alloc] initWithString:@www.mycompany.com]; // assume string exists NSRange selectedRange = NSMakeRange(0, 14); // assume this is set NSURL *linkURL = [NSURL URLWithString:@http://www.mycompany.com;]; [tempCompanyURLString beginEditing]; [tempCompanyURLString addAttribute:NSLinkAttributeName value:linkURL range:selectedRange]; [tempCompanyURLString addAttribute:NSForegroundColorAttributeName value:[NSColor blueColor] range:selectedRange]; [tempCompanyURLString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSSingleUnderlineStyle] range:selectedRange]; [tempCompanyURLString endEditing]; The problem i am facing with the above code is that, if i hover the mouse over the link the pointer doesn't transform to hand symbol and when i click the link its font would change?? Even though i tried to use a windowDidLoad delegate method its not getting called. i am unable to get the desired result of the link not changing the font. please help. thanks, Arjun ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -windowDidLoad not getting called
On Apr 21, 2008, at 5:34 PM, Rick Mann wrote: That's all a rather unfortunate inconsistency (and part of why I sit here learning Cocoa and thinking, I thought Cocoa was supposed to be this great thing). I basically want my controller to go do some stuff after it and the window are loaded. -setWindow seems like an ugly place to do this, and -init is probably too early. Is there a better place? It's not so inconsistent, really. A window controller is intended to be File's Owner for the nib containing a window, not be a separate top- level object in some other nib. If you do that, then the window controller will load the nib itself, and thus load the window within it too and send itself -windowDidLoad at the end. Since your window controller isn't what loaded the nib containing the window, its - windowDidLoad won't be invoked. You could refactor your nib so that your window and its owning window controller are in their own nib, with the window controller as File's Owner; check out Decompose Interface in Interface Builder 3 for an easy tool that will get you partway there. (You'll have to switch from using a separate object to using File's Owner as an instance of your NSWindowController subclass yourself.) NSWindowController isn't the only class in Cocoa that works this way; NSViewController also does, for similar reasons. It's a great substrate on which to build reusable component views. -- Chris ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
-windowDidLoad not getting called
I started a very simple non-document Cocoa app project. I added a controller class derived from NSWindowController, and added an NSObject to my .xib to represent it. I've connected an outlet in my controller to a field in the window, and a button in the window to an action in the controller. I've also set the NSWindowController's window outlet to the window. When the app launches, I see the window, and I can click the button and my action is called (and it updates the field). But, - windowDidLoad is never called. What did I forget? TIA, -- Rick ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
-windowDidLoad not getting called
I started a very simple non-document Cocoa app project. I added a controller class derived from NSWindowController, and added an NSObject to my .xib to represent it. I've connected an outlet in my controller to a field in the window, and a button in the window to an action in the controller. I've also set the NSWindowController's window outlet to the window. When the app launches, I see the window, and I can click the button and my action is called (and it updates the field). But, - windowDidLoad is never called. What did I forget? TIA -- Rick ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: -windowDidLoad not getting called
On Apr 21, 2008, at 6:15 PM, Rick Mann wrote: I started a very simple non-document Cocoa app project. I added a controller class derived from NSWindowController, and added an NSObject to my .xib to represent it. I've connected an outlet in my controller to a field in the window, and a button in the window to an action in the controller. I've also set the NSWindowController's window outlet to the window. When the app launches, I see the window, and I can click the button and my action is called (and it updates the field). But, - windowDidLoad is never called. What did I forget? Sometimes an NSWindowController is instantiated in a NIB as a controller for a window in that same NIB. Other times, an NSWindowController is outside the NIB that contains its window, and is used to load that NIB. I suspect that -windowDidLoad is only called in the latter case. Read the description of the -window and -loadWindow methods, which describes how -windowDidLoad is called. In the former case, the NSWindowController isn't initialized with a NIB. It's just initialized with -init, which is presumably a cover for -initWithWindow:nil. Then, the NIB loading machinery calls its - setWindow: method to connect the outlet. At some later point, you call -window but the window is already loaded in the sense that it's set, so -window doesn't call -loadWindow and friends. I hope that helps, 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: -windowDidLoad not getting called
On Apr 21, 2008, at 5:21 PM, Ken Thomases wrote: Sometimes an NSWindowController is instantiated in a NIB as a controller for a window in that same NIB. Other times, an NSWindowController is outside the NIB that contains its window, and is used to load that NIB. I suspect that -windowDidLoad is only called in the latter case. Read the description of the -window and -loadWindow methods, which describes how -windowDidLoad is called. In the former case, the NSWindowController isn't initialized with a NIB. It's just initialized with -init, which is presumably a cover for -initWithWindow:nil. Then, the NIB loading machinery calls its - setWindow: method to connect the outlet. At some later point, you call -window but the window is already loaded in the sense that it's set, so -window doesn't call -loadWindow and friends. Thanks for the answer. That's all a rather unfortunate inconsistency (and part of why I sit here learning Cocoa and thinking, I thought Cocoa was supposed to be this great thing). I basically want my controller to go do some stuff after it and the window are loaded. -setWindow seems like an ugly place to do this, and -init is probably too early. Is there a better place? -- Rick ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: -windowDidLoad not getting called
On Apr-21-2008, at 6:34 PM, Rick Mann wrote: I basically want my controller to go do some stuff after it and the window are loaded. -setWindow seems like an ugly place to do this, and -init is probably too early. Is there a better place? - (void)awakeFromNib - Jeff ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]