MYSSharedSettings 0.0.2

MYSSharedSettings 0.0.2

LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2016

Maintained by Adam Kirk.

  • By
  • Adam Kirk

Access local settings and settings shared via iCloud with properties.


Add this to your Podfile:

pod 'MYSSharedSettings'


  1. Subclass MYSSharedSettings.
  2. Define properties in .h file.
  3. Add @dynamic statement for each property in .m file.
  4. Set [YourSubclass sharedSettings].syncSettingsWithiCloud = YES; // (or NO) somewhere in your code.


// CVSharedSettings.h

@interface CVSharedSettings : MYSSharedSettings
@property (nonatomic, assign) BOOL remindersEnabled;

// CVSharedSettings.m
@implementation CVSharedSettings
@dynamic remindersEnabled;

Then you read and set the settings properties like normal:

#import "CVSharedSettings.h"

[YourSubclass sharedSettings].syncSettingsWithiCloud = YES;

[CVSharedSettings sharedSettings].remindersEnabled = YES;

if ([CVSharedSettings sharedSettings].remindersEnabled) {
    // ... whatever happens when reminders are enabled

The same properties in your app running on other devices will now have the values you've set.

Providing Defaults

You can override the defaults method to provide defaults for NSUserDefaults:

- (NSDictionary *)defaults
    return @{
         @"remindersEnabled"                    : @YES,
         @"timezoneSupportEnabled"              : @NO,
         @"showDurationOnReadOnlyEvents"        : @NO,
         @"localRootTableViewMode"              : @(CVRootTableViewModeAgenda),
         @"hiddenEventCalendarIdentifiers"      : @[],
         @"customCalendarColors"                : @{},
         @"defaultEventAlarms"                  : @[@(MTDateConstantSecondsInMinute * 15)],
         @"defaultAllDayEventAlarms"            : @[@(MTDateConstantSecondsInHour * 6)],
         @"defaultEventReminder"                : @[@(MTDateConstantSecondsInMinute * 15)],
         @"defaultAllDayReminderAlarms"         : @[@(MTDateConstantSecondsInHour * 6)]


Listen for MYSSharedSettingsChangedNotification to be informed when remotely changed settings arrive.

Transforming Keys

Override - (NSString *)keyForPropertyName:(NSString *)propertyName to transform the property name into the string that will be used as the key when storing the value in NSUserDefaults and NSUbiquitousKeyValueStore.

Excluding Properties From Sync

If you have iCloud syncing enabled but don't want a certain property to be synced, prefix it with local and MYSSharedSettings will only store it in NSUSerDefaults. (e.g. localViewMode)

Pushing Local Settings to iCloud

Call - (void)pushLocalToiCloud to overwrite any settings currently in iCloud with the local settings in NSUserDefaults.