I have the code here reported. The problem is that with my development device it works perfectly, it wait for iCloud and then the method iCloudSync
is called and it works.
With an ad hoc profile for a beta testing user it doesn't work because (i think - because the logging of the method iCloudSync
is not present in console) the NSUbiquitousKeyValueStoreDidChangeExternallyNotification
is not fired.
Where I'm wrong? Thanks
/******** GESTIONE ICLOUD ************/
NSUbiquitousKeyValueStore *iCloudStore = [NSUbiquitousKeyValueStore defaultStore];
if(iCloudStore)
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(iCloudSync)
name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
object:[NSUbiquitousKeyValueStore defaultStore]];
[iCloudStore synchronize];
[[NSUserDefaults standardUserDefaults] setBool:TRUE forKey: iCloudEnabled];
}
else
{
NSLog(@"iCloud is not enabled");
[[NSUserDefaults standardUserDefaults] setBool:FALSE forKey: iCloudEnabled];
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"iCloud not enabled" message:@"iCloud is not working" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertView show];
}
/******** FINE GESTIONE ICLOUD ************/
Your selector look wrong, it should have one and only one argument (cf NSNotificationCenter documentation. You should have
selector:@selector(iCloudSync:) //note the double dot
and your iCloudSync function should look like :
-(void) iCloudSync:(NSNotification *)notification
{
do things...
}
Can you put a log before and after [[NSNotificationCenter defaultCenter]... to confirm you really set it on your AD Hoc Device ?
PS : is "dev" and "AD HOC" Devices the same device or 2 different devices ? I saw a company where iCloud was not allowed via a profil. The users were not able to set iCloud enable....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.