Re: How to save a window's position and size
Re: How to save a window's position and size
- Subject: Re: How to save a window's position and size
- From: Carl Hoefs via Cocoa-dev <email@hidden>
- Date: Fri, 22 May 2020 15:13:05 -0700
The referenced documentation code (©2009) appears to be a wee bit outdated...
Try supplying your own NSString for the auto save name, as [window
representedFilename] no longer seems to return a valid
NSWindowFrameAutosaveName.
In AppDelegate.m I have this and it works:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[self.window setFrameAutosaveName:@"NSWindowFrameAutosaveName"];
}
-Carl
> On May 22, 2020, at 2:22 PM, Gabriel Zachmann via Cocoa-dev
> <email@hidden> wrote:
>
> I am trying to follow these instructions:
>
> https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/WinPanel/Tasks/SavingWindowPosition.html
>
> However, my app doesn't have a NSWindowController.
> It just has a NSViewController and an AppDelegate.
>
> So i thought I could stick the two lines of code mentioned in the doc in one
> of the app delegate's methods.
>
> I tried to put them in applicationDidFinishLaunching, but they don't have an
> effect.
> I tried to define -awakeFromNib in the app delegate and put them there,
> but awakeFromNib never gets called.
>
> I defined -windowDidLoad in the app delegate, but that, too, never gets
> called.
> (However, other methods like windowWillClose or windowDidEndLiveResize do get
> called.)
>
> Any hints how to achieve the goal will be appreciated.
>
> Best regards, Gabriel
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden