I believe you could set a local notifications that will fire each 24 hour then display any quote.
So a day contains 86400 seconds, we could use a timer that will count down from 86400 seconds to zero, when it hits zero we reset the timer and remind them a quote
@IBOutlet weak var label:UILabel!
var countdown = 86400
var timer : NSTimer!
func Notification(){
timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
var notification = UILocalNotification()
notification.fireDate = NSDate(timeIntervalSinceNow: Double(countdown*10))
notification.soundName = UILocalNotificationDefaultSoundName
notification.alertTitle = "Quote is now available"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}
func update(){
countdown--;
if countdown == 0 {
timer.invalidate()
var quote = "God is Great"
self.label.text = quote
}
To show random images when button is clicked :
var counter = 0
@IBOutlet weak var imageView:UIImageView!
@IBAction func ButtonWasTapped(sender:UIButton){
switch(counter){
case 0: imageView.image = UIImage(named: "nameOFtheImage.jpg")
break
case 1: imageView.image = UIImage(named: "nameOFtheImage.jpg")
break
case 2: imageView.image = UIImage(named: "nameOFtheImage.jpg")
break
case 3: imageView.image = UIImage(named: "nameOFtheImage.jpg")
break
case 4: imageView.image = UIImage(named: "nameOFtheImage.jpg")
break
default:
counter = 0
break;
}
counter++
}
15
solved Changing quote xcode 6 [closed]