简体   繁体   English

Swift:应用程序在模拟器中运行良好,但在实际的iPhone上崩溃了吗?

[英]Swift: app runs well in simulator but crashes on actual iPhone?

I am a beginner and I created a kind of tic tac toe game and have been running it on the iPhone 5s simulator to weed out issues and just now I tried it out on my actual iPhone 5s and the app crashes when the AI is supposed to take its turn. 我是一个初学者,我创建了一种tic TAC Toe游戏,并一直在iPhone 5s模拟器上运行它以清除问题,而现在我在实际的iPhone 5s上进行了尝试,并且当AI被认为会导致应用崩溃轮到它了。 Xcode draws an error (EXC_BAD_ACCESS) on the line below: Xcode在下面的行上绘制错误(EXC_BAD_ACCESS):

//Bunch of functions that check for exact spots:

func checktop(value:Int)->(location:String,pattern:String) {
    return ("top", checkFor(value, spots: [1,2,3])) //This line has error
}
func checkbottom(value:Int)->(location:String,pattern:String) {
    return ("bottom", checkFor(value, spots: [7,8,9]))
}
func checkmidAcross(value:Int)->(location:String,pattern:String) {
    return ("middle across", checkFor(value, spots: [4,5,6]))
}
func checkleft(value:Int)->(location:String,pattern:String) {
    return ("left down", checkFor(value, spots: [1,4,7]))
}
func checkmidDown(value:Int)->(location:String,pattern:String) {
    return ("middle down", checkFor(value, spots: [2,5,8]))
}
func checkright(value:Int)->(location:String,pattern:String) {
    return ("right down", checkFor(value, spots: [3,6,9]))
}
func checkLRdiag(value:Int)->(location:String,pattern:String) {
    return ("left-right diagonal", checkFor(value, spots: [1,5,9]))
}
func checkRLdiag(value:Int)->(location:String,pattern:String) {
    return ("right-left diagonal", checkFor(value, spots: [3,5,7]))
}

Why would the app run just fine on the simulator but crash on the actual device? 为什么该应用程序可以在模拟器上正常运行,但在实际设备上崩溃? What's going wrong? 怎么了 Here is my checkFor method: 这是我的checkFor方法:

func checkFor(value:Int, spots:Int[])->(String) {
    var conclusion = ""
    for cell in spots {
        if plays[cell] == value {
            conclusion += "1"
        }
        else {
            conclusion += "0"
        }
    }
    return conclusion
}

func isOccupied(spot:Int)->(Bool) {
    return Bool(plays[spot])
}

My App crashed with the same error on my device but not on the simulator. 我的应用程序崩溃了,但我的设备上却出现了相同的错误,但模拟器上却没有。 It turns out that my iOS 8 beta version did not match my Xcode beta version. 事实证明,我的iOS 8 beta版本与我的Xcode beta版本不匹配。 So I would check and make sure that your iOS 8 beta and Xcode beta are both on version 4 (the latest at the time of this writing). 因此,我将检查并确保您的iOS 8 beta和Xcode beta都在版本4(在撰写本文时为最新版本)上。 Also make sure that you completely reinstall the App, clean build folder etc. 另外,请确保您完全重新安装该应用程序,清理构建文件夹等。

This is of course assuming there is not an error with your code. 当然,这是假设您的代码没有错误。 Maybe you can post your checkFor method if the above does not work. 如果上述方法不起作用,也许可以发布您的checkFor方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使在模拟器上运行,iOS应用程序也会在iPhone上崩溃 - iOS app crashes on an iPhone even though it runs on simulator 我的应用程序在模拟器上正常运行,但在我的 ios 13.2 iPhone 上崩溃 - My app runs properly on the simulator, but crashes on my ios 13.2 iPhone iPhone应用程序在设备上崩溃但在模拟器上没有崩溃 - iPhone app crashes on device but not on simulator 应用程序在iPhone上崩溃,但在模拟器或iPad上没有崩溃? - App crashes on iPhone but not simulator or iPad? ISO App在设备以及模拟器上间歇性崩溃 - ISO App crashes intermittently on device as well as simulator 如果不是64位版本,IOS7应用会在模拟器中崩溃,并且在iPhone4和5s上可以正常运行 - IOS7 app crashes in simulator when not in 64 bits, runs fine on iPhone4 and 5s (iOS)App在iPhone上运行正常,但立即在模拟器中崩溃,未显示任何诊断消息 - (iOS) App runs fine on iPhone but immediately crashes in simulator, no diagnostic messages shown 应用程序在模拟器中运行良好,但在 iphone 中崩溃 - app works well in simulator,But crash in iphone iPhone应用程序在模拟器上工作正常,但在实际设计中崩溃 - Iphone application works fine on simulator but crashes on actual devise 现有的应用程序在iPhone X Simulator上启动时崩溃 - Existing app crashes on startup on iPhone X Simulator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM