Bon Javi Bon Javi - 1 year ago 196
Swift Question

'init()' is deprecated: init() will be removed in Swift 3. Use `nil`

I was using this code.

var audioUnit:AudioUnit = AudioUnit()

But in Xcode 7.3 (Swift 2.2) I am getting this warning. Any idea why? And how can I get rid of that?

N.B. Is I use
then my program crashes.


Answer Source

AudioUnit is a typealais of AudioComponentInstance which itself is a typealais of COpaquePointer. Initializing pointers will be removed with Swift 3.0, just set the variable to nil.

nil and AudioUnit() should do the same thing. If your program is crashing with nil, you probably have a bug somewhere else.

Xcode Playground

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download