From 43392a8d846421b2c120631006589e1b7cbc2bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Zo=CC=88llner?= Date: Thu, 1 Oct 2015 13:34:08 +0300 Subject: [PATCH 1/2] bug fix for empty handler --- Categories/AppKit/NSApplication+BBlock.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } From ad22215e9f48c1a2a4d21a6f63040335af8193c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Zo=CC=88llner?= Date: Sun, 31 Jan 2016 17:30:53 +0200 Subject: [PATCH 2/2] bug fix for crash if completion block is nil --- Categories/AppKit/NSAlert+BBlock.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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