I am updating my app from Swift 3 to Swift 4 and after migration, there are a few errors. One of them is Method 'initialize()' defines Objective-C class method 'initialize', which is not permitted by Swift
in IQToolbar of IQKeyboardManager
, how to fix this?
Asked
Active
Viewed 7,531 times
7

Tamás Sengel
- 55,884
- 29
- 169
- 223

Varun Naharia
- 5,318
- 10
- 50
- 84
1 Answers
1
- You can also use Singleton solve this problem such as:
static let shared : AudioTools = {
$0.initialize()
return $0
}(AudioTools())
Your Objective-C method--->initialize
override class func initialize(){code here}
change:
func initialize(){code here}
Your method here:
func playSound(fileName:String?) {
code here
}
use in Swift3:
let audioPlayer = AudioTools.playMusic(fileName: fileName)
use in Swift4
let audioPlayer = AudioTools.shared.playMusic(fileName: fileName)

user8152635
- 52
- 2
-
I've answered in this link: https://stackoverflow.com/a/46360311/1581772 Where I show you can use a singleton (like @user8152635 does) or where you can use a public static method – Christopher Rex Sep 22 '17 at 08:54