Re: Trouble with NSUserDefaults extension class
Re: Trouble with NSUserDefaults extension class
- Subject: Re: Trouble with NSUserDefaults extension class
- From: Dominik Pich <email@hidden>
- Date: Thu, 31 May 2007 19:47:47 +0200
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:
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