Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么我的Swift程序会停止运行? class GameViewController:UIViewController{ func shuffle(变量列表:C)->C{ 设c=计数(列表) 对于0中的i.._Ios_Swift_Debugging_Uiview_Xcode6 - Fatal编程技术网

Ios 为什么我的Swift程序会停止运行? class GameViewController:UIViewController{ func shuffle(变量列表:C)->C{ 设c=计数(列表) 对于0中的i..

Ios 为什么我的Swift程序会停止运行? class GameViewController:UIViewController{ func shuffle(变量列表:C)->C{ 设c=计数(列表) 对于0中的i..,ios,swift,debugging,uiview,xcode6,Ios,Swift,Debugging,Uiview,Xcode6,开关/案例代码将永远不会运行,因为您已将其放置在函数声明func offWithTheRocks(){…}中,并且从未调用该函数。请尝试删除func offWithTheRocks(){和关联的尾部}您可以通过断点或调试日志缩小暂停的范围吗? class GameViewController: UIViewController { func shuffle<C: MutableCollectionType where C.Index == Int>(var list: C)

开关/案例代码将永远不会运行,因为您已将其放置在函数声明
func offWithTheRocks(){…}
中,并且从未调用该函数。请尝试删除
func offWithTheRocks(){
和关联的尾部
}

您可以通过断点或调试日志缩小暂停的范围吗?
class GameViewController: UIViewController {
    func shuffle<C: MutableCollectionType where C.Index == Int>(var list: C) -> C {
    let c = count(list)
    for i in 0..<(c - 1) {
        let j = Int(arc4random_uniform(UInt32(c - i))) + i
        swap(&list[i], &list[j])
    }
    return list
}
@IBOutlet weak var backround: UIImageView!
@IBOutlet weak var button1: UIButton!
@IBOutlet weak var button2: UIButton!
@IBOutlet weak var button3: UIButton!
@IBOutlet weak var button4: UIButton!
@IBOutlet weak var button5: UIButton!
@IBOutlet weak var Earthy: UIImageView!
@IBOutlet weak var Blocker: UIImageView!
@IBOutlet weak var asteroid5: UIImageView!
@IBOutlet weak var asteroid4: UIImageView!
@IBOutlet weak var asteroid3: UIImageView!
@IBOutlet weak var asteroid2: UIImageView!
@IBOutlet weak var asteroid1: UIImageView!


let realAsteroid = UIImage(named: "Asteroid")
        var numberArray = ["1", "2", "3", "4", "5"]
var playerScore = 0
var aliveOrNah:Bool = true
var positioningNumRock = arc4random_uniform(5) + 1
var positioningNumBlocker = arc4random_uniform(5) + 1

        //set random numbers
override func viewDidLoad(){

    var shuffledNumArray:Array = shuffle(numberArray)
    println(shuffledNumArray)
    var but1String:String = shuffledNumArray[0]
    var but2String:String = shuffledNumArray[1]
    var but3String:String = shuffledNumArray[2]
    var but4String:String = shuffledNumArray[3]
    var but5String:String = shuffledNumArray[4]


    self.button1.setTitle(but1String,forState: UIControlState.Normal)
    self.button2.setTitle(but2String,forState: UIControlState.Normal)
    self.button3.setTitle(but3String,forState: UIControlState.Normal)
    self.button4.setTitle(but4String,forState: UIControlState.Normal)
    self.button5.setTitle(but5String,forState: UIControlState.Normal)
    var posRandNum = arc4random_uniform(5) + 1

    func offWithTheRocks(){
    switch posRandNum{
    case 1:
        self.asteroid1.center.y += view.bounds.height
        UIView.animateWithDuration(10.0, animations: {
            self.asteroid1.center.y -= self.view.bounds.height - 100
        })



    case 2:

        self.asteroid2.center.y += view.bounds.height
        UIView.animateWithDuration(10.0, animations: {
                self.asteroid2.center.y -= self.view.bounds.height - 100
            })


    case 3:

            self.asteroid3.center.y += view.bounds.height
            UIView.animateWithDuration(10.0, animations: {
                self.asteroid3.center.y -= self.view.bounds.height - 100
            })


    case 4:

            self.asteroid4.center.y += view.bounds.height
            UIView.animateWithDuration(10.0, animations: {
                self.asteroid4.center.y -= self.view.bounds.height - 100
            })


    case 5:

            self.asteroid5.center.y += view.bounds.height

                        UIView.animateWithDuration(10.0, animations: {
                self.asteroid5.center.y -= self.view.bounds.height - 100
            })



    default:
        break
    }
    }