相关疑难解决方法(0)

调用可以抛出,但不能从全局变量初始化程序中抛出错误

我正在使用Xcode 7 beta,在迁移到Swift 2后,我遇到了一些代码问题:

let recorder = AVAudioRecorder(URL: soundFileURL, settings: recordSettings as! [String : AnyObject])
Run Code Online (Sandbox Code Playgroud)

我得到一个错误说"调用可以抛出,但错误不能从全局变量初始化程序中抛出".我的应用程序依赖于它recorder是一个全局变量.有没有办法让它保持全球化,但解决这些问题?我不需要高级错误处理,我只是想让它工作.

swift swift2

10
推荐指数
2
解决办法
5574
查看次数

AVAudioPlayer不再适用于Swift 2.0/Xcode 7 beta

对于var testAudio我的iPhone应用程序中的声明,我在这里收到错误

"调用可以抛出,但错误不能从属性初始化程序中抛出"

import UIKit
import AVFoundation
class ViewController: UIViewController {
    var testAudio = AVAudioPlayer(contentsOfURL: NSURL (fileURLWithPath: NSBundle.mainBundle().pathForResource("testAudio", ofType: "wav")!), fileTypeHint:nil)
Run Code Online (Sandbox Code Playgroud)

当我转到Xcode 7测试版时,就发生了这种情况.

如何在Swift 2.0中使用此音频剪辑?

beta xcode ios xcode7

6
推荐指数
1
解决办法
7778
查看次数

标签 统计

beta ×1

ios ×1

swift ×1

swift2 ×1

xcode ×1

xcode7 ×1