gpt4 book ai didi

ios - 使用计时器的 arc4random() 后应用程序崩溃?

转载 作者:行者123 更新时间:2023-11-28 11:23:45 25 4
gpt4 key购买 nike

<分区>

Swift 中,我有一个计时器。每隔一秒,屏幕上的点就会变成不同的点图像。它选择随机显示的点。这就是我想要的。该应用程序在启动时立即崩溃。就像,马上。这个崩溃是怎么解决的?而且,在那之后,它可以与我当前的代码一起使用吗?注释掉一些内容并进行测试后,导致它的行是 imageNumber = Int(arc4random())%13
。这是如何解决的?

我的代码如下:

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var dotChangingTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("changeDot"), userInfo: nil, repeats: true)

var theRandomImages: UIImage[] = [dotOne, dotTwo, dotThree, dotFour, dotFive, dotSix, dotSeven, dotEight, dotNine, dotTen, dotEleven, dotTwelve, dotThirteen]

openingScreenDynamicDot = theRandomImages[Int(imageNumber)]
let finalChangingDotWelcomePage = UIImageView(image: openingScreenDynamicDot)
finalChangingDotWelcomePage.frame = CGRectMake(110, 234, 100, 100)
}
func changeDot() {
println("the images should be changing...")
imageNumber = Int(arc4random())%13

var theRandomImages: UIImage[] = [dotOne, dotTwo, dotThree, dotFour, dotFive, dotSix, dotSeven, dotEight, dotNine, dotTen, dotEleven, dotTwelve, dotThirteen]

openingScreenDynamicDot = theRandomImages[(imageNumber)]
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com