• 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: Preferences binding update NSTextField and user defaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preferences binding update NSTextField and user defaults


  • Subject: Re: Preferences binding update NSTextField and user defaults
  • From: Ferhat Ayaz <email@hidden>
  • Date: Sun, 31 Dec 2006 14:55:34 +0100

you're right. But I've also this part in my code, which will catch all not assigned defaults.

+ (void)setupDefaults
{
    NSString *userDefaultsValuesPath;
    NSDictionary *userDefaultsValuesDict;

// load the default values for the user defaults
userDefaultsValuesPath=[[NSBundle mainBundle] pathForResource:@"UserDefaults"
ofType:@"plist"];
userDefaultsValuesDict=[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath];


// set them in the standard user defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];


}


On Dec 28, 2006, at 2:38 PM, Scott Stevenson wrote:


On Dec 27, 2006, at 2:52 PM, Ferhat Ayaz wrote:

aja, thanks. This is a work around due to leak of auto increment in CoraData.

- (void)awakeFromInsert
{
[super awakeFromInsert];
NSUserDefaultsController *defaults = [NSUserDefaultsController sharedUserDefaultsController];
NSString *num = [[defaults values] valueForKey:@"Counter"];
int counter = [num intValue];
[[defaults values] setValue:[NSString stringWithFormat:@"% d",counter+1] forKey:@"Counter"];
NSString *format = [[defaults values] valueForKey:@"Format"];
[self setValue:[NSString stringWithFormat:format,counter] forKey:@"nr"];
[self setValue:[NSDate date] forKey:@"creationDate"];
}

This probably won't work if the user deletes the application plist file, which is pretty common.


    - Scott
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40googlemail.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Prev by Date: Problem with WebKit Download Delegate
  • Next by Date: Re: NSTableView delete button
  • Previous by thread: Re: Problem with WebKit Download Delegate
  • Next by thread: Re: NSTableView delete button
  • Index(es):
    • Date
    • Thread