Re: How to store main window frame to user defaults?

2011-04-28 Thread Quincey Morris
On Apr 28, 2011, at 04:42, Vyacheslav Karamov wrote: > P.S. But I still can't understand why frame saving code doesn't work from > [NSWindow close] It doesn't work because NSValue objects aren't valid in a property list, which is what the user defaults are. That's why, if you can't using the w

Re: How to store main window frame to user defaults?

2011-04-28 Thread Aaron Burghardt
On Apr 28, 2011, at 7:42 AM, Vyacheslav Karamov wrote: > It works! > Thank you! > > P.S. But I still can't understand why frame saving code doesn't work from > [NSWindow close] > > 28-Apr-11 14:35, Matt Gough пишет: >> How about calling just calling [NSWindow >> setFrameAutosaveName:@"YourAut

Re: How to store main window frame to user defaults?

2011-04-28 Thread Vyacheslav Karamov
It works! Thank you! P.S. But I still can't understand why frame saving code doesn't work from [NSWindow close] 28-Apr-11 14:35, Matt Gough пишет: How about calling just calling [NSWindow setFrameAutosaveName:@"YourAutosaveName"] during awakeFromNib? Matt On 28 Apr 2011, at 11:32, Vyaches

Re: How to store main window frame to user defaults?

2011-04-28 Thread Matt Gough
How about calling just calling [NSWindow setFrameAutosaveName:@"YourAutosaveName"] during awakeFromNib? Matt On 28 Apr 2011, at 11:32, Vyacheslav Karamov wrote: > I can't use Interface builder, because it crashes while opening NIB file. I'm > currently using XCode 3.2.6, but NIB file was crea

Re: How to store main window frame to user defaults?

2011-04-28 Thread Vyacheslav Karamov
I can't use Interface builder, because it crashes while opening NIB file. I'm currently using XCode 3.2.6, but NIB file was created with IB 2.x using plug-in. So, where is it better to save main window frame? I've tried to do do it in [NSWindow close]: - (void) close { NSString * rc = NSString

Re: How to store main window frame to user defaults?

2011-04-28 Thread Aaron Burghardt
Use NSStringFromRect() and NSRectFromString() to convert to/from a string to store in the defaults. However, it might be easier to set frameAutosaveName and let the window save and restore the frame itself. Just enter the key in the autosave attribute in Interface Builder and it should work. Aa

How to store main window frame to user defaults?

2011-04-28 Thread Vyacheslav Karamov
Hi All! I need to save main window size and position to user defaults: NSValue * rect = [NSValue valueWithRect: [[NSApp mainWindow] frame]]; [[NSUserDefaults standardUserDefaults] setObject:rect forKey:@"MainWndFrame"]; but console output is: 2011-04-28 11:45:00.139 UserDefaults[32801:a0f]