Skip to content

Commit

Permalink
feat: add conformsToProtocol forwarding to MPAppDelegateProxy (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaltzer authored and einsteinx2 committed May 16, 2022
1 parent 0244451 commit fc3dce4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mParticle-Apple-SDK/AppNotifications/MPAppDelegateProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ @interface MPAppDelegateProxy() {

@implementation MPAppDelegateProxy

static MPAppDelegateProxy* _defaultProxy = nil;
+ (MPAppDelegateProxy *)defaultProxy {
return _defaultProxy;
}

- (instancetype)initWithOriginalAppDelegate:(id)originalAppDelegate {
_originalAppDelegate = originalAppDelegate;
originalAppDelegateSelector = @selector(originalAppDelegate);
static dispatch_once_t pred = 0;
dispatch_once(&pred, ^{
_defaultProxy = self;
});
return self;
}

Expand Down Expand Up @@ -87,6 +96,12 @@ - (BOOL)respondsToSelector:(SEL)aSelector {
return respondsToSelector;
}

+ (BOOL)conformsToProtocol:(Protocol *)aProtocol {
id original = [[MPAppDelegateProxy defaultProxy] originalAppDelegate];
id surrogate = [[MPAppDelegateProxy defaultProxy] surrogateAppDelegate];
return [original conformsToProtocol:aProtocol] || [surrogate conformsToProtocol:aProtocol];
}

#pragma mark Public accessors
- (MPSurrogateAppDelegate *)surrogateAppDelegate {
if (_surrogateAppDelegate) {
Expand Down

0 comments on commit fc3dce4

Please sign in to comment.