Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds conformsToProtocol forwarding to MPAppDelegateProxy #144

Merged
merged 2 commits into from
Apr 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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