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: Trouble with NSUserDefaults extension class



Aperture.. you are writing a plugin?
If so your code isnt loaded at startup and I think that's the problem: 'plugins cant have categories for code they dont load'!?


Regards,
Dominik

On May 31, 2007, at 7:42 PM, Bryan Hansen wrote:

I am trying to create an extension class for NSUserDefaults so that I can more easily store preference settings for a custom domain. I have created my class with 3 methods:

//  NSUserDefaults+MyExtensions.h

#import <Cocoa/Cocoa.h>

@interface NSUserDefaults (MyExtensions)

- (id)objectForKey:(NSString *)key forPersistentDomain:(NSString *) domain;
- (void)setObject:(id)anObject forKey:(NSString *)key forPersistentDomain:(NSString *)domain;
- (void)removeObjectForKey:(NSString *)key forPersistentDomain: (NSString *)domain;


@end

and then I have about 4 lines in each method that get, set and remove a key in whatever domain they pass in. The trouble is that I crash at runtime with the following error:

Main Thread Exception in Aperture: *** -[NSUserDefaults objectForKey:forPersistentDomain:]: selector not recognized [self = 0x110bf70]

when I use the [NSUserDefaults standardUserDefaults] object. If I init my own NSUserDefaults object it will pick up the my extensions, but I believe I should be using the [NSUserDefaults standardUserDefaults] for things to behave correctly.

Is there any reason why extensions are not working with the singleton instance, standardUserDefaults? Or is there a way to use my own init'ed NSUserDefaults object which won't differ from the standardUserDefaults?


_______________________________________________

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


_______________________________________________

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: 
 >Trouble with NSUserDefaults extension class (From: Bryan Hansen <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.