Swift 1.2 Xcode 6
For a long time, the listener, the first time the caller.
Hello,
Straight from the mouth of the horse: "To handle changes in iCloud availability, register to receive the NSUbiquityIdentityDidChangeNotification notification."
Here is the code they provide for implementation:
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (iCloudAccountAvailabilityChanged:) name: NSUbiquityIdentityDidChangeNotification object: nil];
I changed it in my application:
var observer = NSNotificationCenter.defaultCenter().addObserverForName (NSUbiquityIdentityDidChangeNotification, object: nil, queue: NSOperationQueue.mainQueue() ){...completion block...}
src: https://developer.apple.com/library/ios/documentation/General/Conceptual/iCloudDesignGuide/Chapters/iCloudFundametals.html#//apple_ref/doc/uid/TP40012094-CH6-SW6
What is the correct way to implement this? Does this happen in AppDelegate? Do we remove the observer when the application goes to the background?
The problem that I am facing is that when the Ubiquity token changes, the application still terminates because the user has changed the iCloud settings.
How can you all subscribe to this notification, and if you do not, what do you do to track the current iCloud user?
Thanks!
ios xcode swift icloud
Kevinontheweb
source share