Question

I use core-data for saving a dynamic (small) amount of entities. These entities have a property for "Display" and "Push", which i sync with my server for each entity.

Now i want to add InApp-Settings to give the user the possibility, to change these two settings within the core data entity.

Because the behaviour and look should be like the Settings.app, i want to use the InAppSettingsKit-Project for this case.

As i read, this library allows to implement a custom SettingsStore to save the values within core data, but i need to read the entities and settings from core data too. In my opinion, it is not possible to define a own subclassed IASKSettingsReader for use.

The next problem is, that i want to use the plist on top-level to show the main-settings and then my own-store on a sub-level of the settings.

Example:

-> Display Settings (From plist)
--> List of entities with my own reader and store to show toggles
-> Push Settings (From plist)
--> List of entities with my own reader and store to show toggles 
-> Version (From plist)
-> About (From plist)

Is it possible to accomplish this goal without writing the whole settings from scratch (Which would be very painful and unflexible)?

Thanks for heading me to the right direction in advance!

------EDIT------

I think a possible solution would be, to save a custom plist in the needed format for InAppSettingsKit on app-start, read them in the sub-menu as source for this childpane, save the settings with a custom SettingsStore into the plist and save the data back to core data in the synchronize method.

What do you think about this approach?

Était-ce utile?

La solution 2

I have implemented the approach that i described in the edit of the question.

The whole approach works this way:

  1. Updating the data in core data with content from my server
  2. Generate two plist files in InAppSettingsKit-like plist-Files within the InAppSettings.bundle
  3. Implemented a SettingsStoreCoreData SettingsStore. It builds a dictionary with values from core data on init and saves them back to core-data when synchronize is called.

As Ortwin Gentz mentioned, it is possible to write a own IASKSettingsReader. But i think my approach needs less work and i have not to deal with different source types within IASKSettingsKit.

Autres conseils

The approach you described sounds reasonable. You'll have to tweak the logic to set the path for the plist, though (-locateSettingsFile:). It should also be possible to write a replacement for IASKSettingsReader to dynamically set the field definitions. Alternatively, you could modify the IASKSettingsReader.dataSource property directly (untested, just an idea).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top