所以我是一个非常新的开发人员,今天刚刚推出我的应用程序!太快乐了!
无论如何,我遇到了最难以理解的特殊情况。出于某种原因,在今天应用程序的30次下载中,其中有13次发生了这次崩溃,只有一次。出于某种原因,这只发生一次,似乎只是玩家第一次进入死亡现场。我无法在设备,操作系统或任何随机排序中找到相关性。
以下是crashalytics报告:here
无论如何,下面是正在发生的代码我已经评论了crashalytics认为错误发生的行
func saveHighscore(score:Int) -> Int
{
//authenticateLocalPlayer()
var temp:Int = -99
//var save:Int = -99
//check if user is signed in
if GKLocalPlayer.localPlayer().authenticated
{
var scoreReporter = GKScore(leaderboardIdentifier: "TerribleToothacheSP99") //leaderboard id here
scoreReporter.value = Int64(lscore) //score variable here (same as above)
var scoreArray: [GKScore] = [scoreReporter]
//save = scoreReporter.rank
GKScore.reportScores(scoreArray, withCompletionHandler: {(error : NSError!) -> Void in
if error != nil {
//println("error")
}
})
temp = lbread()
//temp = scoreReporter.rank
}
//return save
return temp
}
var ttoout:Int = -99
func lbread() -> Int
{
var toout:Int = -99
let leaderBoardRequest = GKLeaderboard()
leaderBoardRequest.identifier = "TerribleToothacheSP99"
leaderBoardRequest.loadScoresWithCompletionHandler { (scores, error) -> Void in
//println("STUFF")
if (error != nil) {
//println("Error: \(error!.localizedDescription)")
self.ttoout = -99
} else if (scores != nil) {
let localPlayerScore = leaderBoardRequest.localPlayerScore
//println("Local player's score: \(localPlayerScore.rank)")
toout = localPlayerScore.rank
self.ttoout = localPlayerScore.rank
}
self.recievedScore() //Line 1017 THE CRASH HAPPENS HERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
return toout
}
func recievedScore()
{
if (ttoout == -99)
{
reportext2.text = "Go Online To See Global Ranking"
makeTextInOneLine(reportext2, size: width / 1.2)
}
else
{
//ttoout = 99999999
reportext2.text = "Global Ranking: " + String(ttoout)
makeTextInOneLine(reportext2, size: width / 1.2)
}
}
func makeTextInOneLine(text: SKLabelNodePlus, size: CGFloat) // I am using SKLabelNode+ by maxKargin
{
//println(text.text)
text.drawLabel()
while(text.texture?.size().width > size)
{
text.fontSize -= 1
text.drawLabel()
}
text.drawLabel()
}
如果您对我为什么做某事有任何疑问,或者变量意味着什么,请不要犹豫。非常感谢你看这个!
这是一些额外的代码,包括调用lbread的代码。错误可能没有必要,所以你可能不需要阅读它。
override func didMoveToView(view: SKView){
rnk = saveHighscore(lscore.self)
if (GKLocalPlayer.localPlayer().authenticated == true)
{
reportext2.text = "Waiting for data from scoreboard"
makeTextInOneLine(reportext2, size: width / 1.2)
}
else
{
reportext2.text = "Login to GameCenter to see ranking"
makeTextInOneLine(reportext2, size: width / 1.2)
}
var phs = defaults.integerForKey("THighScore")
if (lscore.self > defaults.integerForKey("THighScore"))
{
//Current score is better then past one
defaults.setInteger(lscore.self, forKey: "THighScore")
hasover = true
}
else
{
//Past score is still reigning champ
}
saveHighscore2(defaults.integerForKey("THighScore"))
}
func saveHighscore2(score:Int)
{
//authenticateLocalPlayer()
var temp:Int = -99
//var save:Int = -99
//check if user is signed in
if GKLocalPlayer.localPlayer().authenticated
{
var scoreReporter = GKScore(leaderboardIdentifier: "TerribleToothacheSP99") //leaderboard id here
scoreReporter.value = Int64(lscore) //score variable here (same as above)
var scoreArray: [GKScore] = [scoreReporter]
//save = scoreReporter.rank
GKScore.reportScores(scoreArray, withCompletionHandler: {(error : NSError!) -> Void in
if error != nil {
//println("error")
}
})
//temp = lbread()
//temp = scoreReporter.rank
}
//return save
//return temp
}
答案 0 :(得分:0)
祝贺你的应用!
快速回答是您应该在主线程中进行UI更新
{{1}}