简体   繁体   English

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

[英]'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. 但是在Xcode 7.3(Swift 2.2)中,我收到了这个警告。 Any idea why? 知道为什么吗? And how can I get rid of that? 我怎么能摆脱它呢?

NB Is I use nil then my program crashes. NB我使用nil然后我的程序崩溃了。

截图

AudioUnit is a typealias of AudioComponentInstance which itself is a typealias of COpaquePointer . AudioUnit是的typealias AudioComponentInstance这本身就是一个typealias COpaquePointer Initializing pointers will be removed with Swift 3.0 , just set the variable to nil . 使用Swift 3.0删除初始化指针 ,只需将变量设置为nil

nil and AudioUnit() should do the same thing. nilAudioUnit()应该做同样的事情。 If your program is crashing with nil , you probably have a bug somewhere else. 如果您的程序崩溃为nil ,则可能在其他地方存在错误。

Xcode游乐场

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM