2 * Copyright (c) 2016 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef CloudKitDependencies_h
25 #define CloudKitDependencies_h
27 #import <ApplePushService/ApplePushService.h>
28 #import <CloudKit/CloudKit.h>
29 #import <Foundation/Foundation.h>
31 NS_ASSUME_NONNULL_BEGIN
33 /* CKModifyRecordZonesOperation */
34 @protocol CKKSModifyRecordZonesOperation
<NSObject
>
35 + (instancetype
)alloc
;
36 - (instancetype
)initWithRecordZonesToSave
:(nullable NSArray
<CKRecordZone
*>*)recordZonesToSave
37 recordZoneIDsToDelete
:(nullable NSArray
<CKRecordZoneID
*>*)recordZoneIDsToDelete
;
39 @
property (nonatomic
, strong
, nullable
) CKDatabase
* database
;
40 @
property (nonatomic
, copy
, nullable
) NSArray
<CKRecordZone
*>* recordZonesToSave
;
41 @
property (nonatomic
, copy
, nullable
) NSArray
<CKRecordZoneID
*>* recordZoneIDsToDelete
;
42 @property NSOperationQueuePriority queuePriority
;
43 @property NSQualityOfService qualityOfService
;
44 @
property (nonatomic
, strong
, nullable
) CKOperationGroup
* group
;
45 @
property (nonatomic
, copy
, null_resettable
) CKOperationConfiguration
*configuration
;
47 @
property (nonatomic
, copy
, nullable
) void (^modifyRecordZonesCompletionBlock
)
48 (NSArray
<CKRecordZone
*>* _Nullable savedRecordZones
, NSArray
<CKRecordZoneID
*>* _Nullable deletedRecordZoneIDs
, NSError
* _Nullable operationError
);
52 @interface
CKModifyRecordZonesOperation (SecCKKSModifyRecordZonesOperation
) <CKKSModifyRecordZonesOperation
>
56 /* CKModifySubscriptionsOperation */
57 @protocol CKKSModifySubscriptionsOperation
<NSObject
>
58 + (instancetype
)alloc
;
59 - (instancetype
)initWithSubscriptionsToSave
:(nullable NSArray
<CKSubscription
*>*)subscriptionsToSave
60 subscriptionIDsToDelete
:(nullable NSArray
<NSString
*>*)subscriptionIDsToDelete
;
62 @
property (nonatomic
, strong
, nullable
) CKDatabase
* database
;
63 @
property (nonatomic
, copy
, nullable
) NSArray
<CKSubscription
*>* subscriptionsToSave
;
64 @
property (nonatomic
, copy
, nullable
) NSArray
<NSString
*>* subscriptionIDsToDelete
;
65 @property NSOperationQueuePriority queuePriority
;
66 @property NSQualityOfService qualityOfService
;
67 @
property (nonatomic
, strong
, nullable
) CKOperationGroup
* group
;
68 @
property (nonatomic
, copy
, null_resettable
) CKOperationConfiguration
*configuration
;
70 @
property (nonatomic
, copy
, nullable
) void (^modifySubscriptionsCompletionBlock
)
71 (NSArray
<CKSubscription
*>* _Nullable savedSubscriptions
, NSArray
<NSString
*>* _Nullable deletedSubscriptionIDs
, NSError
* _Nullable operationError
);
74 @interface
CKModifySubscriptionsOperation (SecCKKSModifySubscriptionsOperation
) <CKKSModifySubscriptionsOperation
>
78 /* CKFetchRecordZoneChangesOperation */
79 @protocol CKKSFetchRecordZoneChangesOperation
<NSObject
>
80 + (instancetype
)alloc
;
81 - (instancetype
)initWithRecordZoneIDs
:(NSArray
<CKRecordZoneID
*>*)recordZoneIDs
82 configurationsByRecordZoneID
:(nullable NSDictionary
<CKRecordZoneID
*, CKFetchRecordZoneChangesConfiguration
*>*)configurationsByRecordZoneID
;
84 @
property (nonatomic
, strong
, nullable
) CKDatabase
*database
;
85 @
property (nonatomic
, copy
, nullable
) NSArray
<CKRecordZoneID
*>* recordZoneIDs
;
86 @
property (nonatomic
, copy
, nullable
) NSDictionary
<CKRecordZoneID
*, CKFetchRecordZoneChangesConfiguration
*>* configurationsByRecordZoneID
;
88 @
property (nonatomic
, assign
) BOOL fetchAllChanges
;
89 @
property (nonatomic
, copy
, nullable
) void (^recordChangedBlock
)(CKRecord
* record
);
90 @
property (nonatomic
, copy
, nullable
) void (^recordWithIDWasDeletedBlock
)(CKRecordID
* recordID
, NSString
* recordType
);
91 @
property (nonatomic
, copy
, nullable
) void (^recordZoneChangeTokensUpdatedBlock
)
92 (CKRecordZoneID
* recordZoneID
, CKServerChangeToken
* _Nullable serverChangeToken
, NSData
* _Nullable clientChangeTokenData
);
93 @
property (nonatomic
, copy
, nullable
) void (^recordZoneFetchCompletionBlock
)(CKRecordZoneID
* recordZoneID
,
94 CKServerChangeToken
* _Nullable serverChangeToken
,
95 NSData
* _Nullable clientChangeTokenData
,
97 NSError
* _Nullable recordZoneError
);
98 @
property (nonatomic
, copy
, nullable
) void (^fetchRecordZoneChangesCompletionBlock
)(NSError
* _Nullable operationError
);
100 @
property (nonatomic
, strong
, nullable
) CKOperationGroup
* group
;
101 @
property (nonatomic
, copy
, null_resettable
) CKOperationConfiguration
*configuration
;
103 @
property (nonatomic
, copy
) NSString
*operationID
;
104 @
property (nonatomic
, readonly
, strong
, nullable
) CKOperationConfiguration
*resolvedConfiguration
;
107 @interface
CKFetchRecordZoneChangesOperation () <CKKSFetchRecordZoneChangesOperation
>
110 /* CKFetchRecordsOperation */
111 @protocol CKKSFetchRecordsOperation
<NSObject
>
112 + (instancetype
)alloc
;
113 - (instancetype
)init
;
114 - (instancetype
)initWithRecordIDs
:(NSArray
<CKRecordID
*>*)recordIDs
;
116 @
property (nonatomic
, strong
, nullable
) CKDatabase
*database
;
117 @
property (nonatomic
, copy
, nullable
) NSArray
<CKRecordID
*>* recordIDs
;
118 @
property (nonatomic
, copy
, nullable
) NSArray
<NSString
*>* desiredKeys
;
119 @
property (nonatomic
, copy
, nullable
) CKOperationConfiguration
* configuration
;
120 @
property (nonatomic
, copy
, nullable
) void (^perRecordProgressBlock
)(CKRecordID
* recordID
, double progress
);
121 @
property (nonatomic
, copy
, nullable
) void (^perRecordCompletionBlock
)
122 (CKRecord
* _Nullable record
, CKRecordID
* _Nullable recordID
, NSError
* _Nullable error
);
123 @
property (nonatomic
, copy
, nullable
) void (^fetchRecordsCompletionBlock
)
124 (NSDictionary
<CKRecordID
*, CKRecord
*>* _Nullable recordsByRecordID
, NSError
* _Nullable operationError
);
127 @interface
CKFetchRecordsOperation () <CKKSFetchRecordsOperation
>
130 /* CKQueryOperation */
132 @protocol CKKSQueryOperation
<NSObject
>
133 + (instancetype
)alloc
;
134 - (instancetype
)initWithQuery
:(CKQuery
*)query
;
135 //Not implemented: - (instancetype)initWithCursor:(CKQueryCursor *)cursor;
137 @
property (nonatomic
, copy
, nullable
) CKQuery
* query
;
138 @
property (nonatomic
, copy
, nullable
) CKQueryCursor
* cursor
;
140 @
property (nonatomic
, copy
, nullable
) CKRecordZoneID
* zoneID
;
141 @
property (nonatomic
, assign
) NSUInteger resultsLimit
;
142 @
property (nonatomic
, copy
, nullable
) NSArray
<NSString
*>* desiredKeys
;
144 @
property (nonatomic
, copy
, nullable
) void (^recordFetchedBlock
)(CKRecord
* record
);
145 @
property (nonatomic
, copy
, nullable
) void (^queryCompletionBlock
)(CKQueryCursor
* _Nullable cursor
, NSError
* _Nullable operationError
);
148 @interface
CKQueryOperation () <CKKSQueryOperation
>
152 @protocol CKKSAPSConnection
<NSObject
>
153 + (instancetype
)alloc
;
154 - (id
)initWithEnvironmentName
:(NSString
*)environmentName
155 namedDelegatePort
:(NSString
*)namedDelegatePort
156 queue
:(dispatch_queue_t
)queue
;
158 - (void)setEnabledTopics
:(NSArray
*)enabledTopics
;
160 @
property (nonatomic
, readwrite
, assign
) id
<APSConnectionDelegate
> delegate
;
163 @interface
APSConnection (SecCKKSAPSConnection
) <CKKSAPSConnection
>
166 /* NSNotificationCenter */
167 @protocol CKKSNSNotificationCenter
<NSObject
>
168 + (instancetype
)defaultCenter
;
169 - (void)addObserver
:(id
)observer selector
:(SEL
)aSelector name
:(nullable NSNotificationName
)aName object
:(nullable id
)anObject
;
170 - (void)removeObserver
:(id
)observer
;
172 @interface
NSNotificationCenter () <CKKSNSNotificationCenter
>
175 /* Since CKDatabase doesn't share any types with NSOperationQueue, tell the type system about addOperation */
176 @protocol CKKSOperationQueue
<NSObject
>
177 - (void)addOperation
:(NSOperation
*)operation
;
180 @interface
CKDatabase () <CKKSOperationQueue
>
183 @interface
NSOperationQueue () <CKKSOperationQueue
>
186 NS_ASSUME_NONNULL_END
188 #endif /* CloudKitDependencies_h */