-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Enable App-Extension-Safe use of API's #669
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// UIApplication+ExtensionSafe.h | ||
// SlackTextViewController | ||
// | ||
// Created by Oskar Groth on 2018-05-22. | ||
// Copyright © 2018 Slack Technologies, Inc. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIApplication (ExtensionSafe) | ||
|
||
+(UIApplication *)safeSharedApplication; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// UIApplication+ExtensionSafe.m | ||
// SlackTextViewController | ||
// | ||
// Created by Oskar Groth on 2018-05-22. | ||
// Copyright © 2018 Slack Technologies, Inc. All rights reserved. | ||
// | ||
|
||
#import "UIApplication+ExtensionSafe.h" | ||
|
||
@implementation UIApplication (ExtensionSafe) | ||
|
||
+ (BOOL)isAppExtension | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unused and unexposed. Do we really need it? |
||
{ | ||
return [[self class] safeSharedApplication] == nil; | ||
} | ||
|
||
+ (UIApplication *)safeSharedApplication | ||
{ | ||
UIApplication *safeSharedApplication = nil; | ||
|
||
if ([UIApplication respondsToSelector:@selector(sharedApplication)]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this logic should probably be executed once and only, by wrapping it in a |
||
safeSharedApplication = [UIApplication performSelector:@selector(sharedApplication)]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling |
||
} | ||
if (!safeSharedApplication.delegate) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
safeSharedApplication = nil; | ||
} | ||
|
||
return safeSharedApplication; | ||
} | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this extension need to be public really?