Created
April 24, 2012 23:22
-
-
Save tonyarnold/2484539 to your computer and use it in GitHub Desktop.
A crashy piece of code under ARC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)dwk_postChangeNotification:(NSString *)notificationName newValue:(id)newValue oldValue:(id)oldValue | |
| { | |
| if (CBIsEmpty(newValue) || CBIsEmpty([self fileModificationDate])) { | |
| return; | |
| } | |
| NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithCapacity:2]; | |
| [userInfo setObject:newValue forKey:kNotificationOldValueKey]; | |
| if (CBIsNotEmpty(oldValue)) { | |
| [userInfo setObject:oldValue forKey:kNotificationNewValueKey]; | |
| } | |
| NSNotification *changeNotification = [NSNotification notificationWithName:notificationName object:self userInfo:userInfo]; | |
| void (^saveCompletionHandler)(BOOL) = [^(BOOL success) { | |
| [[NSNotificationCenter defaultCenter] postNotification:changeNotification]; | |
| } copy]; | |
| // The document has unsaved changes | |
| if (UIDocumentStateNormal != [self documentState]) { | |
| saveCompletionHandler (YES); | |
| } else { | |
| [[DWKDocumentsController sharedController] saveDocumentToDisk:self completionHandler:saveCompletionHandler]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment