編碼和只有學習Swift到目前爲止,在一個過程中使iOS應用程序不更新到IOS 9,當試圖轉換得到這些錯誤的過程中。我已經解決了2個,但這些都超出了我的範圍,我無法前進。請幫忙。使用Swift轉換代碼並得到了多個錯誤
import UIKit
import AVFoundation
class NewSoundViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
var baseString : String = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0]
var pathComponents = [baseString, "MyAudio.m4a"]
var audioNSURL = NSURL.fileURLWithPathComponents(pathComponents)
var session = AVAudioSession.sharedInstance()
do {
try session.setCategory(AVAudioSessionCategoryPlayAndRecord)
} catch _ {
}
var recordSettings: [NSObject : AnyObject] = Dictionary()
recordSettings[AVFormatIDKey] = kAudioFormatMPEG4AAC
recordSettings[AVSampleRateKey] = 44100.0
recordSettings[AVNumberOfChannelsKey] = 2
self.audioRecorder = try AVAudioRecorder(URL: (audioNSURL)!, settings: recordSettings)
self.audioRecorder.meteringEnabled = true
self.audioRecorder.prepareToRecord()
}
Good call在更簡單的Int()語法上顯式創建NSNumber,因爲它會自動轉換爲NSNumber並且看起來更清晰。 –