Code Monkey home page Code Monkey logo

ddicloudsync's Introduction

What is this?

A clean and simple class to sync NSUserDefaults to iCloud. (WITH a delegate for conflict handling. See this [Stackoverflow question][1]

[1]: http://stackoverflow.com/questions/14112942/nsuserdefaults-and-icloud/14113064)

How to use?

  1. Drag the two classes from the DDiCloudSync folder into your projecy and #import the header file in your Application Delegate
  2. init the class: [DDiCloudSync sharedSync] and set a delegate to handle merging potentially conflicting data from local or from iCloud
  3. Call [DDiCloudSync start];

###Example delegate

whenever something is about to be sync'd up, this method is called to provide a final dictionary to send

- (NSDictionary*)mergedDefaultsForUpdatingCloud:(NSDictionary*)dictInCloud withLocalDefaults:(NSDictionary*)dict {
    NSMutableDictionary *newdict = dict.mutableCopy;
    newdict[@"merged"] = @"to icloud";
    return newdict;
}

whenever something is about to be sync'd down, this method is called to provide a final dictionary to write to the defaults

   - (NSDictionary*)mergedDefaultsForUpdatingLocalDefaults:(NSDictionary*)dict withCloud:(NSDictionary*)dictInCloud {
    NSMutableDictionary *newdict = dictInCloud.mutableCopy;
    newdict[@"merged"] = @"from icloud";
    return newdict;
}

important: this is only a mock-implementation of the delegate. You need to put custom app-specific logic here for conflict handling

note: when you dont set a delegate, the class just overwrites the cloud / the local defaults

#####based on original MKiCloudSync code by @mugunthkumar

ddicloudsync's People

Contributors

daij-djan avatar mugunthkumar avatar hout avatar kyoji2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.