I try to convert a Swift 2.2 project to Swift 3 and I get the following error:
Method 'observeValue(forKeyPath:ofObject:change:context:)' with Objective-C selector 'observeValueForKeyPath:ofObject:change:context:' conflicts with method 'observeValue(forKeyPath:of:change:context:)' from superclass 'NSObject' with the same Objective-C selector" for the function call
In my function, whose signature is:
func observeValue(forKeyPath keyPath: String?, ofObject: Any?, change: [String : Any]?, context: UnsafeMutableRawPointer?)."
I read the tip on the Swift 3 translation guide website:
"Workaround: Add the @objc attribute (objectC: name :) before implementing the optional requirement using the Objective-C selector inside."
But I donβt understand how it should be applied in the source file, and none of what I have tried so far has worked successfully.
Can someone explain how to properly configure it?
ios cocoa swift swift3
Cosmo
source share