• 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
Linking a specific controller instance to user defaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Linking a specific controller instance to user defaults


  • Subject: Linking a specific controller instance to user defaults
  • From: Graham Cox <email@hidden>
  • Date: Wed, 5 May 2010 22:42:33 +1000

Another tricky problem...

I have two instances of a particular view controller in my app - however it is not an NSViewController, merely an NSObject that happens to control a view. The two views are identical in function but have distinct uses within the app's GUI as a whole.

The controllers have two particular properties relating to the layout of the view that would be usefully persistent. Making these persistent is very easy, I can simply write the property to the user defaults in the setter, and restore it at some suitable time, say -awakeFromNib (by the way both controller instances are instantiated in different nibs).

The problem should be obvious - how to ensure that each instance of the controller can use a specific unique key in the user defaults. Creating a unique key is easy, but at load time how to calculate the exact same key for the specific instance is not. I thought of adding a 'settings name' property that was used to prefix the key but there's no way to set it earlier than -awakeFromNib time from some external object that "knows" which instance it is using. Ideally the settings name could be set for the instance in IB, but since this is a generic NSObject subclass I can't do that without making an IB plugin just to set it, which seems like major overkill.

Is there another way to set the settings name just in time?

--Graham


_______________________________________________

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: Linking a specific controller instance to user defaults
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Client/Server Design
  • Next by Date: UIPickerView and MKMapView
  • Previous by thread: Re: Client/Server Design
  • Next by thread: Re: Linking a specific controller instance to user defaults
  • Index(es):
    • Date
    • Thread