• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to store main window frame to user defaults?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: Re: How to store main window frame to user defaults?
  • From: Vyacheslav Karamov <email@hidden>
  • Date: Thu, 28 Apr 2011 14:42:03 +0300

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, 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 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 = NSStringFromRect([[NSApp mainWindow] frame]);
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject: rc forKey:@"MainWndFrame"];
[super close];
}

but it doesn't work.


28-Apr-11 12:14, 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.

Aaron

On Apr 28, 2011, at 4:50 AM, Vyacheslav Karamov wrote:

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] *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value 'NSRect: {{525, 701}, {303, 99}}' of class 'NSConcreteValue'.
_______________________________________________

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



_______________________________________________

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


  • Follow-Ups:
    • Re: How to store main window frame to user defaults?
      • From: Quincey Morris <email@hidden>
    • Re: How to store main window frame to user defaults?
      • From: Aaron Burghardt <email@hidden>
References: 
 >How to store main window frame to user defaults? (From: Vyacheslav Karamov <email@hidden>)
 >Re: How to store main window frame to user defaults? (From: Aaron Burghardt <email@hidden>)
 >Re: How to store main window frame to user defaults? (From: Vyacheslav Karamov <email@hidden>)
 >Re: How to store main window frame to user defaults? (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: CoreData: "Could not fulfill a fault", but only sometimes…
  • Next by Date: Re: Stack of NSWindow sheets
  • Previous by thread: Re: How to store main window frame to user defaults?
  • Next by thread: Re: How to store main window frame to user defaults?
  • Index(es):
    • Date
    • Thread