documentation for iCloud methods

This commit is contained in:
John Rommel Estropia
2016-04-30 01:20:35 +09:00
parent 3fe9e4ee1d
commit 0bbb4118a1
5 changed files with 204 additions and 75 deletions

View File

@@ -99,14 +99,19 @@ public class ICloudStore: CloudStorage {
self.storeOptions = storeOptions
}
public func addUbiquitousStoreObserver<T: ICloudStoreObserver>(observer: T) {
/**
Registers an `ICloudStoreObserver` to start receive notifications from the ubiquitous store
- parameter observer: the observer to start sending ubiquitous notifications to
*/
public func addObserver<T: ICloudStoreObserver>(observer: T) {
CoreStore.assert(
NSThread.isMainThread(),
"Attempted to add an observer of type \(typeName(observer)) outside the main thread."
)
self.removeUbiquitousStoreObserver(observer)
self.removeObserver(observer)
self.registerNotification(
&self.willFinishInitialImportKey,
@@ -182,7 +187,12 @@ public class ICloudStore: CloudStorage {
)
}
public func removeUbiquitousStoreObserver(observer: ICloudStoreObserver) {
/**
Unregisters an `ICloudStoreObserver` to stop receiving notifications from the ubiquitous store
- parameter observer: the observer to stop sending ubiquitous notifications to
*/
public func removeObserver(observer: ICloudStoreObserver) {
CoreStore.assert(
NSThread.isMainThread(),

View File

@@ -28,18 +28,77 @@ import Foundation
// MARK: - ICloudStoreObserver
/**
Implement the `ICloudStoreObserver` protocol to observe ubiquitous storage notifications from the specified iCloud store.
Note that `ICloudStoreObserver` methods are only called when all the following conditions are true:
- the observer is registered to the `ICloudStore` via the `ICloudStore.addObserver(_:)` method
- the `ICloudStore` was added to a `DataStack`
- the `ICloudStore` and the `DataStack` are still persisted in memory
*/
public protocol ICloudStoreObserver: class {
/**
Notifies that the initial ubiquitous store import will complete
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreWillFinishUbiquitousStoreInitialImport(storage storage: ICloudStore, dataStack: DataStack)
/**
Notifies that the initial ubiquitous store import completed
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreDidFinishUbiquitousStoreInitialImport(storage storage: ICloudStore, dataStack: DataStack)
/**
Notifies that an iCloud account will be added to the coordinator
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreWillAddAccount(storage storage: ICloudStore, dataStack: DataStack)
/**
Notifies that an iCloud account was added to the coordinator
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreDidAddAccount(storage storage: ICloudStore, dataStack: DataStack)
/**
Notifies that an iCloud account will be removed from the coordinator
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreWillRemoveAccount(storage storage: ICloudStore, dataStack: DataStack)
/**
Notifies that an iCloud account was removed from the coordinator
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreDidRemoveAccount(storage storage: ICloudStore, dataStack: DataStack)
/**
Notifies that iCloud contents will be deleted
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreWillRemoveContent(storage storage: ICloudStore, dataStack: DataStack)
/**
Notifies that iCloud contents were deleted
- parameter storage: the `ICloudStore` instance being observed
- parameter dataStack: the `DataStack` that manages the peristent store
*/
func iCloudStoreDidRemoveContent(storage storage: ICloudStore, dataStack: DataStack)
}