저는 Swift에서 초보자이며 현재 학교 프로젝트 용 앱을 제작 중입니다."스레드 1 : 중단 점 3.5"오류
'Thread 1: breakpoint 3.5'
내가 온라인 검색 한 : 내 응용 프로그램을 테스트하기 위해 노력했다 때 을 '빌드 성공'그러나 갑자기 폐쇄하고 ViewController.swift 화면에 오류가있는 녹색 선을했다 말했다 가능한 모든 답변을 찾았지만 찾을 수 없었습니다. 누군가 나를 친절하게 도와 줄 수 있습니까? 고맙습니다!
업데이트 : 이제 '스레드 1 : EXC_BAD_INSTRUCTION (code = EXC_I386_INVOP, subcode = 0x0)'오류가 발생합니다. 나는 수색했고 나는 이것을 고치는 법을 모른다. .. 누군가? 여기
코드입니다 : 사진 (1) 아래의 다음 링크에 설명 된대로 모든 중단 점 네비게이터로 이동의import UIKit
import AVFoundation
class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate
{
@IBOutlet weak var pickerView: UIPickerView!
var pickerDataSource = ["White", "Red", "Green", "Blue"];
override func viewDidLoad() {
super.viewDidLoad()
self.pickerView.dataSource = self;
self.pickerView.delegate = self;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerDataSource.count;
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
return pickerDataSource[row]
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
{
if(row == 0)
{
self.view.backgroundColor = UIColor.whiteColor();
}
else if(row == 1)
{
self.view.backgroundColor = UIColor.redColor();
}
else if(row == 2)
{
self.view.backgroundColor = UIColor.greenColor();
}
else
{
self.view.backgroundColor = UIColor.blueColor();
}
};
var audioPlayer = AVAudioPlayer() // This is where the error occurs
@IBAction func PlaySound(sender: UISwipeGestureRecognizer) {
// Set the sound file name & extension
let alertSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("woosh", ofType: "mp3")!)
do {
// Preperation
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
} catch _ {
}
do {
try AVAudioSession.sharedInstance().setActive(true)
} catch _ {
}
// Play the sound
do {
audioPlayer = try AVAudioPlayer(contentsOfURL: alertSound)
} catch _{
}
audioPlayer.prepareToPlay()
audioPlayer.play()
}
}
시도가 VAR의 audioPlayer AVAudioPlayer =() 라인에서의 브레이크 포인트를 제거한다. 우연히 설정할 수 있습니다. –
감사합니다.하지만 시뮬레이터가 공백으로 표시되고 오류가 계속 발생합니다 ... – lemontree