• 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: Subject: [ NSSplitview ] -setAutosaveName
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subject: [ NSSplitview ] -setAutosaveName


  • Subject: Re: Subject: [ NSSplitview ] -setAutosaveName
  • From: Erg Consultant <email@hidden>
  • Date: Sun, 31 May 2009 00:37:25 -0700 (PDT)

Ok so more specifically I should have asked:

How do I get the NSSplitView to restore the divider position when my app relaunches the next time?

I set the autosave name but when I drag the splitter, then quit and relaunch, it's still in the default position, not the position it was in when I quit.

Erg




________________________________
From: Caleb Strockbine <email@hidden>
To: email@hidden
Cc: email@hidden
Sent: Sunday, May 31, 2009 12:19:34 AM
Subject: Subject: [ NSSplitview ] -setAutosaveName


On May 31, 2009, at 12:10 AM, email@hidden wrote:

What does setAutosaveName actually do? I assume it saves the position of the splitview to user defaults?

Did you read the fine manual? It's fairly plain:

"Sets the name under which receiver’s divider position is automatically saved... If this value is nil or the string is empty no autosaving is done."

So, if you set the autosave name for a split view to something other than nil, the split view will automatically save its position using the name that you gave it. The autosave name isn't something that you'd normally want to change after the splitter is set up -- you set it either in Interface Builder or in whatever code creates the splitter, and then forget about it.


If so, how does one retrieve that value?


Typically, one doesn't. The split view will use the autosave name you gave it to retrieve the data from the defaults system and set itself appropriately. Your app shouldn't need to worry about the position of the splitters themselves -- they're not controls, and they shouldn't affect the state of your application. To whatever extent you do care about the position of the splitters, you can/should probably rely on the sizes of the split view's subviews instead. However, if you do want to peek at the data that the split view is saving (for logging purposes, perhaps), you can always retrieve the split view's data from the defaults system yourself:

id savedData = [[NSUserDefaults standardUserDefaults] valueForKey:[slider autosaveName]];

I used an id above because you really can't know for certain what kind of data NSSplitView is saving. It's probably an array, since there can be more than one splitter in a split view, but it could be something else.

-Caleb



_______________________________________________

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

References: 
 >Subject: [ NSSplitview ] -setAutosaveName (From: Caleb Strockbine <email@hidden>)

  • Prev by Date: Subject: [ NSSplitview ] -setAutosaveName
  • Next by Date: NSTableViewSelectionHighlightStyleSourceList interferes with custom NSBrowserCell drawing
  • Previous by thread: Subject: [ NSSplitview ] -setAutosaveName
  • Next by thread: NSTableViewSelectionHighlightStyleSourceList interferes with custom NSBrowserCell drawing
  • Index(es):
    • Date
    • Thread