不推荐使用'init()':在Swift 3中删除init()。使用`nil`

时间:2016-05-05 19:12:38

标签: ios swift swift2 audiounit opaque-pointers

我正在使用此代码。

var audioUnit:AudioUnit = AudioUnit()

但是在Xcode 7.3(Swift 2.2)中,我收到了这个警告。知道为什么吗?我怎么能摆脱它?

N.B。我使用nil然后我的程序崩溃。

screenshot

1 个答案:

答案 0 :(得分:12)

AudioUnitAudioComponentInstance的类型,其本身是COpaquePointer的类型。 Initializing pointers will be removed with Swift 3.0,只需将变量设置为nil

nilAudioUnit()应该做同样的事情。如果你的程序崩溃了nil,你可能在其他地方有一个错误。

Xcode Playground