Home > other >  How to fill out an abstract method?
How to fill out an abstract method?

Time:01-19

I'm using an SDK (AdColony) to show ads to the users. There is an abstract method in the AdColonyZone object.

Here is the header file: https://github.com/AdColony/AdColony-iOS-SDK/blob/master/AdColony.xcframework/ios-arm64_armv7/AdColony.framework/Headers/AdColonyZone.h

The reference to method I used (setReward) is on line 78:

- (void)setReward:(nullable void (^)(BOOL success, NSString *name, int amount))reward;

The documentation: https://github.com/AdColony/AdColony-iOS-SDK/wiki/Showing-Rewarded-Interstitial-Ads

The example code from the documentation:

let rewardedZones:Array<String> = [/* Rewarded Zone IDs */]
AdColony.configure(withAppID: /* App ID */, zoneIDs: /* Zone IDs */, options: nil) { [weak self] (zones) in
    for zone in zones {
        if rewardedZones.contains(zone.identifier) {
            zone?.setReward = { [weak self] (success, name, amount) in
                if success {
                    self?.rewardUser(coinsAmount: amount, currencyName: name)
                }
            }
        }
    }
}

Here is my code:

AdColony.configure(withAppID: "MY_APP_ID", zoneIDs: ["MY_ZONE_ID"], options: nil){ (zones) in
    for zone in zones {
        zone.setReward = { (success, name, amount) in
            if success {
                // TODO: Something...
            }
        }
    }
}

I'm not able to set "setReward". I'm getting this error:

error: cannot assign to value: 'setReward' is a method
zone.setReward = { (success, name, amount) in
                    ~~~~~^~~~~~~~~

How can I set the setReward handler?

CodePudding user response:

AdColony.configure(withAppID: "MY_APP_ID", zoneIDs: ["MY_ZONE_ID"], options: nil){ (zones) in
    for zone in zones {
        zone.setReward { success, name, amount in
            if success {
                // TODO: Something...
            }
        }
    }
}
  •  Tags:  
  • Related