我正在尝试创建一个可以随机接收本地通知的应用。我使用了一些代码,但效果不佳。它只会来'" 006"或" 005",它不会改变。
我使用的代码是:
let myArray = ["000", "001", "002", "003", "004", "005", "006"]
let notification = UILocalNotification()
notification.alertBody = myArray[Int(arc4random_uniform(UInt32(myArray.count)))] // text that will be displayed in the notification
notification.fireDate = NSDate() // right now (when notification will be fired)
notification.soundName = UILocalNotificationDefaultSoundName // play default sound
notification.repeatInterval = NSCalendarUnit.NSHourCalendarUnit // this line defines the interval at which the notification will be repeated
UIApplication.sharedApplication().scheduleLocalNotification(notification)
你可以告诉我哪里弄错了吗?感谢。