I'm currently jumping into project built by different developer in swift over a year ago. I'm aware swift changed through that time so there are few issues coming to me.
There is beacon library calling delegate method in objective c class called:
- (void)beaconManager:(ESTBeaconManager *)manager
didRangeBeacons:(NSArray *)beacons
inRegion:(ESTBeaconRegion *)region;
and method that gets call from delegate in swift class:
func beaconManager(manager: ESTBeaconManager, didRangeBeacons: [ESTBeacon], inRegion: ESTBeaconRegion) {
//code..
}
swift method compile with Error:
Objective-C method
beaconManager:didRangeBeacons:inRegion:
provided by methodbeaconManager(_:didRangeBeacons:inRegion:)
conflicts with optional requirement methodbeaconManager(_:didRangeBeacons:inRegion:)
in protocolESTBeaconManagerDelegate
答案 0 :(得分:0)
Your method parameteres are optional, because in Objective-C you can pass a nil as an argument while you can not do that in Swift if the parameter is not optional. You need something like this.
func beaconManager(manager: ESTBeaconManager!, didRangeBeacons: [ESTBeacon]!, inRegion: ESTBeaconRegion!) {
//code..
}