Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preferences binding update NSTextField and user defaults




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Preferences binding update NSTextField and user defaults (From: Ferhat Ayaz <email@hidden>)
 >Re: Preferences binding update NSTextField and user defaults (From: mmalc crawford <email@hidden>)
 >Re: Preferences binding update NSTextField and user defaults (From: Ferhat Ayaz <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.