2016年6月12日 星期日

CAMediaTimingFunction

Basically I want to make a dots animation view like this.


So I look into the CAMediaTimingFunction and it's a bezier function.

https://en.wikipedia.org/wiki/B%C3%A9zier_curve

There is a website that you can view your bezier curve in CAMediaTimingFunction

http://netcetera.org/camtf-playground.html

So I just create 3 dots with different CAMediaTimingFunction that changes alpha like this.




But eventually it don't really have to use CAMediaTimingFunction to approach this. Just create animation groups will be more precise.


2016年6月2日 星期四

iCloud Key-value storage development


The goal is store your app preference to iCloud for backup. That only involved to the key-value storage of iCould.

To use iCloud in an app. You need to configure the in the apple develop like this





Where you can store different type of data like .


Which only key-value storage don't need a container, others are needed a container to store the data in. Look into the apple document would be more helpful.

iCloudDesignGuide

Once you setup the iCould, you could be able to access NSUbiquitous store


    [NSUbiquitousKeyValueStore defaultStore]

and store your key-value data like UserDefault to the ubiquitouskeyvaluestore
  
    [[NSUbiquitousKeyValueStore defaultStore] setObject:obj forKey:key];
    [[NSUbiquitousKeyValueStore defaultStore] synchronize];


and you register a notification of the key
NSUbiquitousKeyValueStoreDidChangeExternallyNotification


And analysis the notification you will get the key-value backup from your iCould account.

    NSDictionary *userInfo = [notificationObject userInfo];
    NSInteger reasonForChangeValue = [[userInfo objectForKey:NSUbiquitousKeyValueStoreChangeReasonKey] integerValue];
        
     if (reasonForChangeValue == NSUbiquitousKeyValueStoreInitialSyncChange)
    {
          // your merge code here
    }


That's it.
You can take look into the
https://github.com/hydrated/iOS-Utilities/tree/master/iCouldSync 


Furthermore you want to make more functionality,
NSUbiquitousKeyValueStoreChangeReasonKey has 4 values can be listening notification. like account change , violate limitation storage.