Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I create my own store by subclassing of IASKAbstractSettingsStore?
    primarykey
    data
    text
    <p>First off, InAppSettingsKit is just what I was looking for. Once I figure out some things it will save me tons of time.</p> <p>My question is: how do I create my own store by subclassing IASKAbstractSettingsStore? The <a href="http://inappsettingskit.com" rel="nofollow">home of IASK</a> states: </p> <blockquote> <p>The default behaviour of IASK is to store the settings in [NSUserDefaults standardUserDefaults]. However, it is possible to change this behaviour by setting the settingsStore property on an IASKAppSettingsViewController.</p> </blockquote> <p>and</p> <blockquote> <p>The easiest way to create your own store is to create a subclass of IASKAbstractSettingsStore.</p> </blockquote> <p>I've spent a good deal of time combing through the code, and I think I understand the basic structure of it. However, I can't figure out <strong><em>how</em></strong> and <strong><em>what</em></strong> to set the settingsStore property to.</p> <p>I can see the settingsStore defined and implemented in IASKAppSettingsViewController:</p> <pre><code>id&lt;IASKSettingsStore&gt; _settingsStore; </code></pre> <p>and</p> <pre><code>- (id&lt;IASKSettingsStore&gt;)settingsStore { if (!_settingsStore) { _settingsStore = [[IASKSettingsStoreUserDefaults alloc] init]; } return _settingsStore; </code></pre> <p>}</p> <p>I tried subclassing IASKAbstractSettingsStore:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "IASKSettingsStore.h" @interface IASKSettingsStoreMeals : IASKAbstractSettingsStore { NSString * _filePath; NSMutableDictionary * _dict; } - (id)initWithPath:(NSString*)path; @end </code></pre> <p>and then modified IASKAppSettingsViewController's settingsStore property to allocate and initialize my new class IASKSettingsStoreMeals instead of IASKSettingsStoreUserDefaults - the only way I can see to change the property:</p> <pre><code>- (id&lt;IASKSettingsStore&gt;)settingsStore { if (!_settingsStore) { _settingsStore = [[IASKSettingsStoreMeals alloc] init]; } return _settingsStore; </code></pre> <p>}</p> <p>When I build and run, I get the following message when I try the first control (the toggle switch), all other fields do not get saved:</p> <pre><code>attempt to insert nil value at objects[0] (key: toggleSwitch) </code></pre> <p>What am I doing wrong? In addition to the changes needed to "rejigger" the code to use IASKSettingsStoreFile (or a subclassed IASKAbstractSettingsStore), I also can't see where to set the file path change the location of where the settings are saved - or is that done behind the scenes. Looking forward to get past this learning curve and using this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload