2016-08-01 30 views
0

我是Swift的初学者,目前我正在为一个学校项目构建一个应用程序。当我想测试我的应用程序,它说“构建成功”但随后突然倒闭,和ViewController.swift屏幕上它与该错误的绿线:我在网上搜索“线程1:断点3.5”错误

'Thread 1: breakpoint 3.5'

为任何可能的答案,但我找不到任何。有人能帮助我吗?谢谢!

更新:现在有一个错误说'线程1:EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 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() 



    } 
} 
+1

尝试从var audioPlayer = AVAudioPlayer()行删除制动点。你可以意外设置它。 –

+0

谢谢,但现在模拟器只是空白,错误仍然存​​在... – lemontree

回答

0

首先,你会在某个应用程序看到一个断点。点击它,然后只需按下键盘上的删除按钮。这应该可以解决您的问题。

Image1

+0

让我知道如果这有帮助,请。 –

+0

如果它**没有工作,请确保您的应用程序有一个入口点,在'故事板'(因为你说模拟器变为空白)。如果没有,转到第一个'ViewController',到**属性检查器**,并检查:'是初始视图控制器' –

+0

谢谢,但我的代码中没有断点,第一个入口点屏幕。还有其他解决方案吗?谢谢! – lemontree