10

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 nil then my program crashes.

screenshot

JAL
  • 41,701
  • 23
  • 172
  • 300

1 Answers1

12

AudioUnit is a typealias of AudioComponentInstance which itself is a typealias 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

JAL
  • 41,701
  • 23
  • 172
  • 300
  • @JarrodSmith please make sure when you edit someone else's answer you use a valid link. I've made an edit which corrected your invalid hyperlink. – JAL Jun 20 '16 at 12:41