Skip to content

Commit

Permalink
fix: Infinite recursion when custom config is used (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
einsteinx2 committed Jan 10, 2023
1 parent 2b828a0 commit 8232001
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mParticle-iterable/MPKitIterable.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ @interface MPKitIterable() <IterableURLDelegate>
@implementation MPKitIterable

@synthesize kitApi = _kitApi;
static IterableConfig *_customConfig = nil;
static NSURL *_clickedURL = nil;
static __strong IterableConfig *_customConfig = nil;
static __strong id <IterableURLDelegate> _customUrlDelegate = nil;
static __strong NSURL *_clickedURL = nil;

+ (NSNumber *)kitCode {
return @1003;
Expand All @@ -24,13 +25,16 @@ + (void)load {

+ (void)setCustomConfig:(IterableConfig *_Nullable)config {
_customConfig = config;
_customUrlDelegate = config.urlDelegate;
}

- (BOOL)handleIterableURL:(NSURL *)url context:(IterableActionContext *)context {
BOOL result = YES;
if (_customConfig.urlDelegate != nil && [((NSObject *)_customConfig.urlDelegate) respondsToSelector:@selector(handleIterableURL:context:)]) {
result = [_customConfig.urlDelegate handleIterableURL:url context: context];
} else if (_customConfig.urlDelegate != nil) {
if (_customUrlDelegate == self) {
NSLog(@"mParticle -> Error: Iterable urlDelegate was set in custom config but points to the MKKitIterable instance. It should be a different object.");
} else if (_customUrlDelegate != nil && [((NSObject *)_customUrlDelegate) respondsToSelector:@selector(handleIterableURL:context:)]) {
result = [_customUrlDelegate handleIterableURL:url context: context];
} else if (_customUrlDelegate != nil) {
NSLog(@"mParticle -> Error: Iterable urlDelegate was set in custom config but didn't respond to the selector 'handleIterableURL:context:'");
}

Expand Down

0 comments on commit 8232001

Please sign in to comment.