dhennessy/PAPreferences

Creating a BasePreferences class for different targets to subclass

Closed this issue · 1 comments

I love this class, and have been using it to drive preferences for many different targets in my project.

Today I decided to try to reduce the amount of code that was getting duplicated each time I created a new target. Instead of using a direct subclass of PAPreferences directly:

  • PAPreferences
    • MyPreferences // where all my @properties are defined

I wanted to create a base class, and then each target would simply implement a subclass of that:

  • PAPreferences
    • MyPreferencesBase // where all my @properties are defined
      • MyPreferences // now I just have to tweak each @Property in the init

Unfortunately this isn't proving successful. I'm getting "unrecognized selector sent to instance" when trying to access a @Property in MyPreferences that has been defined in MyPreferencesBase.

Am I doing something wrong or is this type of setup unsupported?

Thanks again for the wonderful class.

I'm not sure why the subclassing isn't working - you'd have to actually debug the accessors.

In my project, it's always made sense to initialize the properties in the same class that defined them.