basically, i want to know if a device has icloud account signed-in, if yes, i'll store to icloud, if no, i'll store to my server. i am using objective-c on xcode6. i am currently using key-value store feature of icloud and everything works fine by now, but my problem is, how can i know if my device has icloud account signed-in? i am using these codes but it doesn't help because both codes return NO
- (BOOL)isCloudSetup
{
id token = [[NSFileManager defaultManager] ubiquityIdentityToken];
return token != nil;
}
- (void)refreshiCloudRoot:(void (^)(BOOL available))completion
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
_iCloudRoot = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (_iCloudRoot != nil) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"iCloud available at: %@",_iCloudRoot);
completion(YES);
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"iCloud not available");
completion(NO);
});
}
});
}
thanks in advance for those who can help.