diff --git a/Categories/AppKit/NSAlert+BBlock.m b/Categories/AppKit/NSAlert+BBlock.m index fac6311..54cf09d 100644 --- a/Categories/AppKit/NSAlert+BBlock.m +++ b/Categories/AppKit/NSAlert+BBlock.m @@ -20,7 +20,7 @@ -(void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(N - (void)_alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { void (^handler)(NSInteger returnCode) = objc_getAssociatedObject(self, &BBlockSheetKey); [alert.window orderOut:nil]; - handler(returnCode); + if (handler) handler(returnCode); objc_setAssociatedObject(self, &BBlockSheetKey, nil, OBJC_ASSOCIATION_COPY_NONATOMIC); } @end diff --git a/Categories/AppKit/NSApplication+BBlock.m b/Categories/AppKit/NSApplication+BBlock.m index 7e23931..068f71f 100644 --- a/Categories/AppKit/NSApplication+BBlock.m +++ b/Categories/AppKit/NSApplication+BBlock.m @@ -31,7 +31,7 @@ - (void)_sheetDidEnd:(NSWindow*)sheet void (^handler)(NSInteger returnCode) = objc_getAssociatedObject(self, &BBlockSheetKey); [sheet orderOut:nil]; - handler(returnCode); + if (handler) handler(returnCode); objc_setAssociatedObject(self, &BBlockSheetKey, nil, OBJC_ASSOCIATION_COPY_NONATOMIC); }