From a1eeb57ad6785fb709e84bfbfb2b06cba76c8eb5 Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Wed, 4 Mar 2015 16:07:46 +0100 Subject: Fix accessibility-related crashes on older OS X releases (#47). The NSAccessibilityPriorityKey symbol was only introduced in 10.9, so that we have to check for its availability before using it, otherwise we get a SIGSEGV. --- Framework/MASShortcutView.m | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Framework') diff --git a/Framework/MASShortcutView.m b/Framework/MASShortcutView.m index d96989c..1e1a0d8 100644 --- a/Framework/MASShortcutView.m +++ b/Framework/MASShortcutView.m @@ -137,12 +137,15 @@ NSString *const MASShortcutBinding = @"shortcutValue"; [self activateResignObserver:_recording]; [self setNeedsDisplay:YES]; - // Give VO users feedback on the result - if (_recording == NO) { - NSString* msg = (_shortcutValue.description) ? - NSLocalizedString(@"Shortcut set", @"VoiceOver shortcut recording feedback") : - NSLocalizedString(@"Shortcut cleared", @"VoiceOver shortcut recording feedback"); - NSDictionary *announcementInfo = [[NSDictionary alloc] initWithObjectsAndKeys:msg, NSAccessibilityAnnouncementKey, @"High", NSAccessibilityPriorityKey, nil]; + // Give VoiceOver users feedback on the result. Requires at least 10.9 to run. + if (_recording == NO && (&NSAccessibilityPriorityKey != NULL)) { + NSString* msg = _shortcutValue ? + NSLocalizedString(@"Shortcut set", @"VoiceOver: Shortcut set") : + NSLocalizedString(@"Shortcut cleared", @"VoiceOver: Shortcut cleared"); + NSDictionary *announcementInfo = @{ + NSAccessibilityAnnouncementKey : msg, + NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh), + }; NSAccessibilityPostNotificationWithUserInfo(self, NSAccessibilityAnnouncementRequestedNotification, announcementInfo); } } -- cgit v1.2.3