Re: Problem with NSUserDefaultsController
Re: Problem with NSUserDefaultsController
- Subject: Re: Problem with NSUserDefaultsController
- From: Mark Allan <email@hidden>
- Date: Mon, 1 Sep 2008 21:01:30 +0100
On Sun, Aug 31, 2008 at 12:13 PM, Mark Allan
<email@hidden> wrote:
For what it's worth, I also get these compiler warnings for the line with
[sharedUserDefaultsController save:]
warning: multiple methods named '-save:' found
warning: using '-(void)save:(id)sender'
warning: also found '-(BOOL)save:(NSError **)error'
The compiler doesn't know which method you're trying to invoke,
because +[NSUserDefaultsController sharedUserDefaultsController] is
typed to return id. You need to cast the return value of this method
call as an NSUserDefaultsController to satisfy the compiler.
Thank you, I didn't realise that. Why is it typed to return id,
surely the only thing it could ever return is an
NSUserDefaultsController object?
Also, you aren't storing the value of [super init] in self, which is
incorrect. Your -init method needs to look like this:
-(id)init
{
if(self = [super init]) // one = is intentional
{
> NSUserDefaultsController *shared =
[NSUserDefaultsController sharedUserDefaultsController];
[shared setAppliesImmediately:NO];
myPrefs = [NSUserDefaults standardUserDefaults];
[self readPrefs];
}
return self;
}
This probably won't address your problem, but it's important.
No, it didn't, but it's worth getting into the habit of doing it
properly even in test apps, so thanks again.
Mark
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden