Skip to content

Commit

Permalink
Changed saveChangesToDocumentWithName: to be deprecated instead of ju…
Browse files Browse the repository at this point in the history
…st deleting it
  • Loading branch information
JackJackBauer committed Dec 3, 2013
1 parent e752af4 commit ce15256
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 2 deletions.
9 changes: 9 additions & 0 deletions iCloud.framework/Versions/A/Headers/iCloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ NS_CLASS_AVAILABLE_IOS(5_1) @interface iCloud : NSObject
@param handler Code block called when the document is successfully saved. The completion block passes UIDocument and NSData objects containing the saved document and it's contents in the form of NSData. The NSError object contains any error information if an error occurred, otherwise it will be nil. */
- (void)saveAndCloseDocumentWithName:(NSString *)documentName withContent:(NSData *)content completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler __attribute__((nonnull));

/** DEPRECATED. Use saveAndCloseDocumentWithName: instead. Record changes made to a document in iCloud. Changes are saved when the document is closed.
@deprecated This method is deprecated starting in version 7.1. Use methodNameHere: instead. This method may become unavailable in a future version.
@param documentName The name of the document being written to iCloud. This value must not be nil.
@param content The data to write to the document
@param handler Code block called when the document changes are recorded. The completion block passes UIDocument and NSData objects containing the saved document and it's contents in the form of NSData. The NSError object contains any error information if an error occurred, otherwise it will be nil. */
- (void)saveChangesToDocumentWithName:(NSString *)documentName withContent:(NSData *)content completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler __attribute__((nonnull)) __deprecated;

/** Upload any local files that weren't created with iCloud
@discussion Files in the local documents directory that do not already exist in iCloud will be **moved** into iCloud one by one. This process involves lots of file manipulation and as a result it may take a long time. This process will be performed on the background thread to avoid any lag or memory problems. When the upload processes end, the completion block is called on the main thread.
Expand Down
Binary file modified iCloud.framework/Versions/A/iCloud
Binary file not shown.
Binary file modified iCloud.framework/iCloud
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions iCloud/iCloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ NS_CLASS_AVAILABLE_IOS(5_1) @interface iCloud : NSObject
@param handler Code block called when the document is successfully saved. The completion block passes UIDocument and NSData objects containing the saved document and it's contents in the form of NSData. The NSError object contains any error information if an error occurred, otherwise it will be nil. */
- (void)saveAndCloseDocumentWithName:(NSString *)documentName withContent:(NSData *)content completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler __attribute__((nonnull));

/** DEPRECATED. Use saveAndCloseDocumentWithName: instead. Record changes made to a document in iCloud. Changes are saved when the document is closed.
@deprecated This method is deprecated starting in version 7.1. Use methodNameHere: instead. This method may become unavailable in a future version.
@param documentName The name of the document being written to iCloud. This value must not be nil.
@param content The data to write to the document
@param handler Code block called when the document changes are recorded. The completion block passes UIDocument and NSData objects containing the saved document and it's contents in the form of NSData. The NSError object contains any error information if an error occurred, otherwise it will be nil. */
- (void)saveChangesToDocumentWithName:(NSString *)documentName withContent:(NSData *)content completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler __attribute__((nonnull)) __deprecated;

/** Upload any local files that weren't created with iCloud
@discussion Files in the local documents directory that do not already exist in iCloud will be **moved** into iCloud one by one. This process involves lots of file manipulation and as a result it may take a long time. This process will be performed on the background thread to avoid any lag or memory problems. When the upload processes end, the completion block is called on the main thread.
Expand Down
63 changes: 61 additions & 2 deletions iCloud/iCloud.m
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,70 @@ - (void)saveAndCloseDocumentWithName:(NSString *)documentName withContent:(NSDat
}

/*
This method is obsolete: Due to the fact, that the document is recreated in closed state on every call, it just is s copy of the saveAndCloseDocumentWithName-method above
This method is deprecated: Due to the fact, that the document is recreated in closed state on every call, it just is s copy of the saveAndCloseDocumentWithName-method above
*/

- (void)saveChangesToDocumentWithName:(NSString *)documentName withContent:(NSData *)content completion:(void (^)(UIDocument *cloudDocument, NSData *documentData, NSError *error))handler {

[self saveAndCloseDocumentWithName:documentName withContent:content completion:handler];

/*
// Log save
if (verboseLogging == YES) NSLog(@"[iCloud] Beginning document change save");
// Check for iCloud
if ([self quickCloudCheck] == NO) return;
// Check for nil / null document name
if (documentName == nil || [documentName isEqualToString:@""]) {
// Log error
if (verboseLogging == YES) NSLog(@"[iCloud] Specified document name must not be empty");
NSError *error = [NSError errorWithDomain:@"The specified document name was empty / blank and could not be saved. Specify a document name next time." code:001 userInfo:nil];
handler(nil, nil, error);
return;
}
// Get the URL to save the changes to
NSURL *fileURL = [[self ubiquitousDocumentsDirectoryURL] URLByAppendingPathComponent:documentName];
// 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 ([fileManager fileExistsAtPath:[fileURL path]]) {
// Log recording
if (verboseLogging == YES) NSLog(@"[iCloud] Document exists, saving changes");
// Record Changes
[document updateChangeCount:UIDocumentChangeDone];
handler(document, document.contents, nil);
} else {
// Log saving
if (verboseLogging == YES) NSLog(@"[iCloud] Document is new, saving");
// Save and create the new document
[document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
if (success) {
// Log the save
if (verboseLogging == YES) NSLog(@"[iCloud] New document created successfully, recorded changes");
// Run the completion block and pass the document
handler(document, document.contents, nil);;
} else {
NSLog(@"[iCloud] Error while creating the document: %s", __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"]];
handler(document, document.contents, error);
}
}];
}
*/
}
*/

- (void)uploadLocalOfflineDocumentsWithRepeatingHandler:(void (^)(NSString *documentName, NSError *error))repeatingHandler completion:(void (^)(void))completion {
// Log upload
Expand Down

0 comments on commit ce15256

Please sign in to comment.