7

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?

Tamás Sengel
  • 51,886
  • 29
  • 155
  • 197
Varun Naharia
  • 5,100
  • 9
  • 47
  • 81

1 Answers1

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) 
  • 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