Created
July 4, 2016 03:10
-
-
Save Raztor0/1fe06b6ff1d2fecb8c9cbdc09611b42e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ubiquitousKeyValueStoreDidChange:) name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification object:[NSUbiquitousKeyValueStore defaultStore]]; | |
[[NSUbiquitousKeyValueStore defaultStore] synchronize]; | |
return YES; | |
} | |
#pragma mark - NSNotifications | |
- (void)ubiquitousKeyValueStoreDidChange:(NSNotification*)notification { | |
NSUbiquitousKeyValueStore *ubiquitousKeyValueStore = notification.object; | |
NSString *UUID; | |
if ((UUID = [ubiquitousKeyValueStore stringForKey:@"UUID"])) { | |
NSLog(@"Got UUID: %@", UUID); | |
} else { | |
UUID = [[NSUUID UUID] UUIDString]; | |
[ubiquitousKeyValueStore setString:UUID forKey:@"UUID"]; | |
NSLog(@"Set UUID: %@", UUID); | |
} | |
[ubiquitousKeyValueStore synchronize]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment