• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSUserDefaultsController in a NIB when not using standardUserDefaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUserDefaultsController in a NIB when not using standardUserDefaults


  • Subject: Re: NSUserDefaultsController in a NIB when not using standardUserDefaults
  • From: Alex Kac <email@hidden>
  • Date: Mon, 08 Sep 2014 13:39:33 -0600

Hi Alex. Xcode will also complain if you don’t call super. You must call super and assign it to self…but then it seems that you are free to re-assign self - which I kinda get - the parent class might be doing important stuff in super…maybe there’s a more primitive init method I can override.

Ideally though, we don’t even do this. Ideally, there is a better way to handle a custom suite for bindings with a NIB.


> On Sep 8, 2014, at 1:15 PM, Alex Zavatone <email@hidden> wrote:
>
> Stupid question, but what happens if you don't assign the first self to the result of the call, but just call [super initWithCoder: coder]?
>
> Do you need the result of that call, since you immediately override it?
>
>
> Sent from my iPad
>
> On Sep 8, 2014, at 2:09 PM, Alex Kac <email@hidden> wrote:
>
>> This feels like there should be an easy answer...
>>
>> We are no longer using standardUserDefaults since we want to someday offer a widget for our app that will require accessing our app's preferences..so we're using NSUserDefaults with a custom suiteName.
>>
>> *The question is*:  in the NIBs for our Preference panes, we had various UI elements bound to NSUserDefaultsController.  The normal NSUserDefaultsController in IB is set to only use standardUserDefaults.  Is there any way to have it use our userdefaults instead?
>>
>> I did come up with one way - but I don't I love it.  I made a subclass of NSUserDefaultsController and in the initWithCoder method, I tell it to use our defaults...of course, I have to first call super or else I'll get a compiler warning (which feels like a waste and causes me to re-assign self)...so here's what I have now:
>>
>> - (instancetype)initWithCoder:(NSCoder *)coder
>> {
>>    self = [super initWithCoder: coder]
>>    self = (MyUserDefaultsController *)[[NSUserDefaultsController alloc] initWithDefaults: myUserDefaults initialValues:nil];
>>
>>    return self;
>> }
>>
>>
>> Is there a better way?
>>
>>
>> _______________________________________________
>>
>> 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

Alex Kac - President and Founder
Web Information Solutions, Inc.

My wife and I do a lot of things together including Halo 3 and firearm training. She's awesome.








_______________________________________________

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


References: 
 >NSUserDefaultsController in a NIB when not using standardUserDefaults (From: Alex Kac <email@hidden>)
 >Re: NSUserDefaultsController in a NIB when not using standardUserDefaults (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: NSUserDefaultsController in a NIB when not using standardUserDefaults
  • Next by Date: Re: Add bindings for custom menu items' isHidden to (an attribute of) a custom object?
  • Previous by thread: Re: NSUserDefaultsController in a NIB when not using standardUserDefaults
  • Next by thread: Re: NSUserDefaultsController in a NIB when not using standardUserDefaults
  • Index(es):
    • Date
    • Thread