Hello.

Before all, I checked on google and the Docs for info, and I don't see what I 
might be doing wrong.

This is what Im doing, following the AppPref example but of course for a 
desktop app.

In my  - (void)applicationDidFinishLaunching:(NSNotification *)aNotification{

I have the following:

id testValue =[[NSUserDefaults standardUserDefaults] 
objectForKey:kNotPayedGradientKey];
                                        
        if(testValue == nil){ //No values yet registered
        //..Creating NSGradients and Put converting them as NSData
        _notPayedGradient = [[NSGradient alloc] initWithStartingColor:[NSColor 
colorWithCalibratedRed:_notPayedRedColor green:_notPayedGreenColor 
blue:_notPayedBlueColor                                                         
                                                      alpha:1.0f]   
endingColor:[NSColor colorWithCalibratedRed:_notPayedRedColor + 0.1 
green:_notPayedGreenColor + 0.1                                                 
                                                                                
      blue:_notPayedBlueColor + 0.1 alpha:1.0f]];
                
        NSData * notPayedData = [NSKeyedArchiver 
archivedDataWithRootObject:_notPayedGradient];
        
then after creating all the gradients I do:

NSDictionary * appDefaults = [NSDictionarydictionaryWithObjectsAndKeys:
                                notPayedData,kNotPayedGradientKey
                                ,partPayedData,kPartPayedGradientKey,
                                payedData,kPayedGradientKey,nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
if([[NSUserDefaults standardUserDefaults] synchronize])NSLog(@"Could Save");

So, I ran my app, and as expected I enter the if statement,  and I see in the 
console, the  "Could Save" message.

I ran again, expecting not to enter the if statement, but for my surprise it 
came in again. the testValue is always nil. I change then:

NSString * testValue = [NSUserDefaults standardUserDefaults] 
stringForKey:kNotPayedGradientKey]; 

to see if the given key existed, but still nothing. I went to checn the .plist 
in the /users/<USER>/library/preferences, and there my old 
com.mycompany.<appName>.plist, but there is nothing inside,  I change then the 
target identifier to something else, and when running and going into the 
preferences folder there is no such a ,plist... 

What can I do?, what am I doing wrong?

Thx in advance any help will be appreciate it.

Gustavo.




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to