Skip to content

Commit 43a9e15

Browse files
(fix) add a cast to nsobject in order to avoid a build error in objective-c… (#379)
* add a cast to nsobject in order to avoid a build error in objective-c. Swift works fine. :/ * update travis yaml to user testapp master. add comments
1 parent dd704d4 commit 43a9e15

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
env:
3434
- SDK=objective-c
3535
- BUILD_NUMBER=$TRAVIS_BUILD_NUMBER
36+
- TESTAPP_TAG=master
3637
cache: false
3738
before_install: skip
3839
install:

OptimizelySDKShared/OptimizelySDKShared/OPTLYManagerBase.m

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,11 @@ - (void)cleanUserProfileService:(NSArray<OPTLYExperiment *><OPTLYExperiment> *)e
8686
//#pragma clang diagnostic push
8787
//#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
8888
@try {
89-
IMP imp = [self.userProfileService.class instanceMethodForSelector:selector];
89+
// cast to NSObject. If the user profile service is not the default service, then an exception will be thrown when trying to access this selector.
90+
IMP imp = [((NSObject *)(self.userProfileService)).class instanceMethodForSelector:selector];
91+
// cast the function
9092
void (*func)(id, SEL, NSArray *) = (void *)imp;
93+
// call it.
9194
func(self.userProfileService, selector, ids);
9295
}
9396
@catch(NSException *e) {

0 commit comments

Comments
 (0)