-
-
Notifications
You must be signed in to change notification settings - Fork 178
/
iCloud.m
executable file
·497 lines (423 loc) · 27.8 KB
/
iCloud.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
//
// iCloud.m
// iCloud Document Sync
//
// Originally from iCloudPlayground
//
// Created by iRare Media on 3/23/13.
//
//
#import "iCloud.h"
@interface iCloud () {
UIBackgroundTaskIdentifier backgroundProcess;
}
- (void)enumerateCloudDocuments;
+ (void)updateFilesWithDelegate:(id<iCloudDelegate>)delegate;
- (void)doNothingAtAll;
- (void)startUpdate;
@end
@implementation iCloud
@synthesize query;
@synthesize previousQueryResults;
@synthesize updateTimer;
@synthesize fileList;
@synthesize delegate;
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Setup --------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Setup
- (id)init {
// Setup Starter Sync
self = [super init];
if (self) {
// Check iCloud Availability
[iCloud checkCloudAvailability];
// No Know Docs Yet - Initialize Array
self.fileList = [NSMutableArray array];
self.previousQueryResults = [NSMutableArray array];
// Sync and Update Documents List
[self enumerateCloudDocuments];
// [iCloud updateFilesWithDelegate:delegate];
// Add a timer that updates out for changes in the file metadata
updateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(doNothingAtAll) userInfo:nil repeats:NO];
}
return self;
}
+ (NSMetadataQuery *) query {
static NSMetadataQuery* q = nil;
if (q == nil) {
q = [[NSMetadataQuery alloc] init];
}
return q;
}
+ (NSMutableArray *) fileList {
static NSMutableArray* f = nil;
if (f == nil) {
f = [NSMutableArray array];
}
return f;
}
+ (NSMutableArray *) previousQueryResults {
static NSMutableArray* p = nil;
if (p == nil) {
p = [NSMutableArray array];
}
return p;
}
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Check --------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Check
+ (BOOL)checkCloudAvailability {
// Check for iCloud Availability by finsing the Ubiquity URl of the app
NSURL *returnedURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (returnedURL){
NSLog(@"iCloud is available at the following URL\n%@", returnedURL);
return YES;
} else {
#if TARGET_IPHONE_SIMULATOR
// Simulator
NSLog(@"iCloud is not available in the iOS Simulator. Please run this app on a device to test iCloud.");
#else
// Device
NSLog(@"iCloud is not available. iCloud may be unavailable for a number of reasons:\n• The device has not yet been configured with an iCloud account, or the Documents & Data option is disabled\n• Your app, %@, does not have properly configured entitlements\nGo to http://bit.ly/15ECEWj for more information on setting up iCloud", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]);
#endif
return NO;
}
}
- (void)doNothingAtAll {
// For some strange reason, deleting this method and the line that creates the timer that calls it causes iCloud not to function and the app to crash... If anyone can figure out this mystery, please submit a pull request / issue on Github at https://github.com/iRareMedia/iCloudDocumentSync
}
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Sync ---------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Sync
- (void)enumerateCloudDocuments {
// Setup iCloud Metadata Query
// self.query = [[NSMetadataQuery alloc] init];
[[iCloud query] setSearchScopes:[NSArray arrayWithObjects:NSMetadataQueryUbiquitousDocumentsScope, nil]];
[[iCloud query] setPredicate:[NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%%K like '*.*'"], NSMetadataItemFSNameKey]];
// Pull a list of all the documents in the cloud
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startUpdate) name:NSMetadataQueryDidFinishGatheringNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startUpdate) name:NSMetadataQueryDidUpdateNotification object:nil];
[[iCloud query] startQuery];
}
- (void)startUpdate {
[iCloud updateFilesWithDelegate:delegate];
}
+ (void)updateFilesWithDelegate:(id<iCloudDelegate>)delegate {
// Create and Update the list of files
// Start Process on Background Thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^{
// Disable updates to iCloud while we update to avoid errors
[[iCloud query] disableUpdates];
NSMutableArray *discoveredFiles = [NSMutableArray array];
// The query reports all files found, every time.
NSArray *queryResults = [[iCloud query] results];
for (NSMetadataItem *result in queryResults) {
NSURL *fileURL = [result valueForAttribute:NSMetadataItemURLKey];
NSNumber *aBool = nil;
// Don't include hidden files
[fileURL getResourceValue:&aBool forKey:NSURLIsHiddenKey error:nil];
if (aBool && ![aBool boolValue])
[discoveredFiles addObject:fileURL];
}
// Get File Names in from the Query
NSMutableArray *names = [NSMutableArray array];
for (NSMetadataItem *item in [iCloud query].results) {
[names addObject:[item valueForAttribute:NSMetadataItemFSNameKey]];
}
dispatch_async(dispatch_get_main_queue(), ^{
if ([delegate respondsToSelector:@selector(iCloudFilesDidChange:withNewFileNames:)])
[delegate iCloudFilesDidChange:discoveredFiles withNewFileNames:names];
});
// Reenable Updates
[[iCloud query] enableUpdates];
});
}
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Add ----------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Add
+ (void)saveDocumentWithName:(NSString *)name withContent:(NSData *)content completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^{
// Run process on the background thread
// Get the URL to save the new file to
NSURL *folderURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
folderURL = [folderURL URLByAppendingPathComponent:DOCUMENT_DIRECTORY];
NSURL *fileURL = [folderURL URLByAppendingPathComponent:name];
// Initialize a document with that path
iCloudDocument *document = [[iCloudDocument alloc] initWithFileURL:fileURL];
document.contents = content;
// If the file exists, close it; otherwise, create it.
if ([[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]]) {
// Save and close the document
[document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:^(BOOL success) {
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
handler(document, document.contents, nil);
});
} else {
NSLog(@"%s error while saving", __PRETTY_FUNCTION__);
NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"%s error while saving the document, %@, to iCloud", __PRETTY_FUNCTION__, document.fileURL] code:110 userInfo:[NSDictionary dictionaryWithObject:fileURL forKey:@"FileURL"]];
dispatch_async(dispatch_get_main_queue(), ^{
handler(document, document.contents, error);
});
}
}];
} else {
// Save and create the new document, then close it
[document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
if (success) {
// Saving implicitly opens the file. An open document will restore the its (remotely) deleted file representation.
[document closeWithCompletionHandler:nil];
// Run the completion block and pass the document
dispatch_async(dispatch_get_main_queue(), ^{
// Run process on the main thread
handler(document, document.contents, nil);
});
} else {
NSLog(@"%s error while creating the document in iCloud", __PRETTY_FUNCTION__);
NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"%s error while creating the document, %@, in iCloud", __PRETTY_FUNCTION__, document.fileURL] code:100 userInfo:[NSDictionary dictionaryWithObject:fileURL forKey:@"FileURL"]];
dispatch_async(dispatch_get_main_queue(), ^{
handler(document, document.contents, error);
});
}
}];
}
});
}
+ (void)uploadLocalOfflineDocumentsWithDelegate:(id<iCloudDelegate>)delegate repeatingHandler:(void (^)(NSString *fileName, NSError *error))repeatingHandler completion:(void (^)(void))completion {
// Perform tasks on background thread to avoid problems on the main / UI thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^{
// Get the array of files in the documents directory
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSArray *localDocuments = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];
NSLog(@"Local Files: %@", localDocuments);
// Compare the arrays then upload documents not already existent in iCloud
for (int item = 0; item < [localDocuments count]; item++) {
NSLog(@"Items: %i", item);
// Check to make sure the documents aren't hidden
if (![[localDocuments objectAtIndex:item] hasPrefix:@"."]) {
// If the file does not exist in iCloud, upload it
if (![[iCloud previousQueryResults] containsObject:[localDocuments objectAtIndex:item]]) {
NSLog(@"Uploading %@ to iCloud...", [localDocuments objectAtIndex:item]);
// Move the file to iCloud
NSURL *destinationURL = [[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%@",[localDocuments objectAtIndex:item]]];
NSError *error;
NSURL *directoryURL = [NSURL fileURLWithPath:[documentsDirectory stringByAppendingPathComponent:[localDocuments objectAtIndex:item]]];
BOOL success = [[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:directoryURL destinationURL:destinationURL error:&error];
if (success == NO) {
NSLog(@"Error while uploading document from local directory: %@",error);
dispatch_async(dispatch_get_main_queue(), ^{
repeatingHandler([localDocuments objectAtIndex:item], error);
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
repeatingHandler([localDocuments objectAtIndex:item], nil);
});
}
} else {
// Check if the local document is newer than the cloud document
// Get the file URL for the iCloud document
NSURL *folderURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSURL *cloudFileURL = [[folderURL URLByAppendingPathComponent:DOCUMENT_DIRECTORY] URLByAppendingPathComponent:[localDocuments objectAtIndex:item]];
NSURL *localFileURL = [NSURL fileURLWithPath:[documentsDirectory stringByAppendingPathComponent:[localDocuments objectAtIndex:item]]];
// Create the UIDocument object from the URL
iCloudDocument *document = [[iCloudDocument alloc] initWithFileURL:cloudFileURL];
NSDate *cloudModDate = document.fileModificationDate;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[localFileURL absoluteString] error:nil];
NSDate *localModDate = [fileAttributes fileModificationDate];
NSData *localFileData = [[NSFileManager defaultManager] contentsAtPath:[localFileURL absoluteString]];
if ([cloudModDate compare:localModDate] == NSOrderedDescending) {
NSLog(@"The iCloud file was modified more recently than the local file. The local file will be deleted and the iCloud file will be preserved.");
NSError *error;
if (![[NSFileManager defaultManager] removeItemAtPath:[localFileURL absoluteString] error:&error]) {
NSLog(@"Error deleting %@.\n\n%@", [localFileURL absoluteString], error);
}
} else if ([cloudModDate compare:localModDate] == NSOrderedAscending) {
NSLog(@"The local file was modified more recently than the iCloud file. The iCloud file will be overwritten with the contents of the local file.");
// Set the document's new content
document.contents = localFileData;
// Save and close the document in iCloud
[document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:^(BOOL success) {
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
repeatingHandler([localDocuments objectAtIndex:item], nil);
});
} else {
NSLog(@"%s error while overwriting old iCloud file", __PRETTY_FUNCTION__);
NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"%s error while saving the document, %@, to iCloud", __PRETTY_FUNCTION__, document.fileURL] code:110 userInfo:[NSDictionary dictionaryWithObject:[localDocuments objectAtIndex:item] forKey:@"FileName"]];
dispatch_async(dispatch_get_main_queue(), ^{
repeatingHandler([localDocuments objectAtIndex:item], error);
});
}
}];
} else {
NSLog(@"The local file and iCloud file have the same modification date. Before overwriting or deleting, iCloud Document Sync will check if both files have the same content.");
if ([[NSFileManager defaultManager] contentsEqualAtPath:[cloudFileURL absoluteString] andPath:[localFileURL absoluteString]] == YES) {
NSLog (@"The contents of the local file and the contents of the iCloud file match. The local file will be deleted.");
NSError *error;
if (![[NSFileManager defaultManager] removeItemAtPath:[localFileURL absoluteString] error:&error]) {
NSLog(@"Error deleting %@.\n\n%@", [localFileURL absoluteString], error);
}
} else {
NSLog (@"Both the iCloud file and the local file were last modified at the same time, however their contents do not match. You'll need to handle the conflict using the iCloudFileUploadConflictWithCloudFile:andLocalFile: delegate method.");
NSDictionary *cloudFile = [[NSDictionary alloc] initWithObjects:@[document.contents, cloudFileURL, cloudModDate]
forKeys:@[@"fileContents", @"fileURL", @"modifiedDate"]];
NSDictionary *localFile = [[NSDictionary alloc] initWithObjects:@[localFileData, localFileURL, localModDate]
forKeys:@[@"fileContents", @"fileURL", @"modifiedDate"]];;
if ([delegate respondsToSelector:@selector(iCloudFileUploadConflictWithCloudFile:andLocalFile:)])
[delegate iCloudFileUploadConflictWithCloudFile:cloudFile andLocalFile:localFile];
}
}
}
} else {
// The file is hidden, do not proceed
dispatch_async(dispatch_get_main_queue(), ^{
NSError *error = [[NSError alloc] initWithDomain:@"File in directory is hidden and will not be uploaded to iCloud." code:520 userInfo:[NSDictionary dictionaryWithObject:[localDocuments objectAtIndex:item] forKey:@"FileName"]];
repeatingHandler([localDocuments objectAtIndex:item], error);
});
}
}
dispatch_async(dispatch_get_main_queue(), ^{
completion();
});
});
}
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Read ---------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Read
+ (void)retrieveCloudDocumentWithName:(NSString *)documentName completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul), ^{
// Get the URL to get the file from
NSURL *folderURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSURL *fileURL = [[folderURL URLByAppendingPathComponent:DOCUMENT_DIRECTORY] URLByAppendingPathComponent:documentName];
// Create the UIDocument object from the URL
iCloudDocument *document = [[iCloudDocument alloc] initWithFileURL:fileURL];
// If the file exists open it; otherwise, create it
NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:[fileURL path]]) {
[document openWithCompletionHandler:^(BOOL success){
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
handler(document, document.contents, nil);
});
} else {
NSLog(@"%s error while retrieving document", __PRETTY_FUNCTION__);
NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"%s error while retrieving document, %@, from iCloud", __PRETTY_FUNCTION__, document.fileURL] code:200 userInfo:[NSDictionary dictionaryWithObject:fileURL forKey:@"FileURL"]];
dispatch_async(dispatch_get_main_queue(), ^{
handler(document, document.contents, error);
});
}
}];
} else {
// Save the new document to disk
[document saveToURL:fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
dispatch_async(dispatch_get_main_queue(), ^{
handler(document, document.contents, nil);
});
}];
}
});
}
+ (BOOL)doesFileExistInCloud:(NSString *)fileName {
// Get the URL to get the file from
NSURL *folderURL = [[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:DOCUMENT_DIRECTORY];
NSURL *fileURL = [folderURL URLByAppendingPathComponent:fileName];
// Check if the file exists, and return
if ([[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]]) {
return YES;
} else {
return NO;
}
}
+ (NSArray *)getListOfCloudFiles {
// Create iCloud Documents Directory URL
NSURL *folderURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSURL *fileURL = [folderURL URLByAppendingPathComponent:DOCUMENT_DIRECTORY];
// Get the directory contents
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:fileURL includingPropertiesForKeys:nil options:0 error:nil];
return directoryContent;
}
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Share --------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Share
+ (NSURL *)shareDocumentWithName:(NSString *)name completion:(void (^)(NSURL *sharedURL, NSDate *expirationDate, NSError *error))handler {
// Get the URL to get the file from
NSURL *folderURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSURL *fileURL = [[folderURL URLByAppendingPathComponent:DOCUMENT_DIRECTORY] URLByAppendingPathComponent:name];
// Create the Error Object and the Date Object
NSError *error;
NSDate *date;
// Create the URL
NSURL *url = [[NSFileManager defaultManager] URLForPublishingUbiquitousItemAtURL:fileURL expirationDate:&date error:&error];
// Pass the data to the handler
handler(url, date, error);
// Return the URL
return url;
}
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Delete -------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Delete
+ (void)deleteDocumentWithName:(NSString *)name completion:(void (^)(NSError *error))handler {
// Create the File Manager
NSFileManager *fileManager = [NSFileManager defaultManager];
// Create the URL for the file that is being removed
NSURL *folderURL = [[fileManager URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:DOCUMENT_DIRECTORY];
NSURL *fileURL = [folderURL URLByAppendingPathComponent:name];
// Start Process on Background Thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Create the UIDocument Object
__block iCloudDocument *document = [[iCloudDocument alloc] initWithFileURL:fileURL];
// Close the document before deleting
[document closeWithCompletionHandler:^(BOOL success){
if (success) {
// Set the Document to NIL
document = nil;
// Create the Error Handler
NSError *error;
// Remove the file at the specified URL
[fileManager removeItemAtURL:fileURL error:&error];
if (error) {
dispatch_async(dispatch_get_main_queue(), ^{
handler(error);
});
return;
} else {
dispatch_async(dispatch_get_main_queue(), ^{
handler(nil);
});
return;
}
} else {
// The document failed to close, return an error
NSLog(@"%s error while closing document", __PRETTY_FUNCTION__);
NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:@"%s error while closing document, %@, from iCloud", __PRETTY_FUNCTION__, document.fileURL] code:300 userInfo:[NSDictionary dictionaryWithObject:fileURL forKey:@"FileURL"]];
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{
handler(error);
});
return;
});
}
}];
});
}
//---------------------------------------------------------------------------------------------------------------------------------------------//
//------------ Deprecated Methods -------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------//
#pragma mark - Deprecated Methods
+ (void)deleteDocumentWithName:(NSString *)name withDelegate:(id<iCloudDelegate>)delegate completion:(void (^)(NSError *error))handler {
NSLog(@"\n\n---------- WARNING ----------\nThe iCloud Document Sync method, [deleteDocumentWithName: withDelegate: completion:], is deprecated. This method no longer does anything - calling it will have no effect and will not delete any documents. Please use the newer, [deleteDocumentWithName: completion:], method instead.\n\n---------- WARNING ----------\n\n");
}
+ (void)saveDocumentWithName:(NSString *)name withContent:(NSData *)content withDelegate:(id<iCloudDelegate>)delegate completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler {
NSLog(@"\n\n---------- WARNING ----------\nThe iCloud Document Sync method, [saveDocumentWithName: withContent: withDelegate: completion:], is deprecated. This method no longer does anything - calling it will have no effect and will not save any documents. Please use the newer, [saveDocumentWithName: withContent: completion:], method instead.\n\n---------- WARNING ----------\n\n");
}
+ (void)uploadLocalOfflineDocumentsWithDelegate:(id<iCloudDelegate>)delegate completion:(void (^)(NSError *error))handler {
NSLog(@"\n\n---------- WARNING ----------\nThe iCloud Document Sync method, [uploadLocalOfflineDocumentsWithDelegate: completion:], is deprecated. This method no longer does anything - calling it has no effect and will not upload any documents. Please use the newer, [uploadLocalDocumentsWithHandler: completion:], method instead.\n\n---------- WARNING ----------\n\n");
}
@end