每天从.plist文件生成报价

时间:2016-06-06 04:21:59

标签: ios swift plist

此问题与:Update Every Day in swift syntax有关,除了数组外,它是一个.plist文件,其中所有引号和作者都是字符串。

如何通过从设置的.plist文件中选择随机引用,让我的应用每天早上8点更改报价?

    //=========================//
    //=========New Quote=======//
    //=======================//

    // Generates Random Number
    func randomNumber(arrayLength: Int) -> Int {
        let unsignedArrayCount = UInt32(arrayLength)
        let unsignedRandomNumber = arc4random_uniform(unsignedArrayCount)
        let randomNumber = Int(unsignedRandomNumber)


        return randomNumber
    }

    // Importing Quotes plist File
    let BooksQuoteScreen = ImportBookList(FileName: "BookList")

    // Selects Quote
    let chosenQuote: String! = BooksQuoteScreen.array[randomNumber(BooksQuoteScreen
        .count())] as! String
    let chosenAuthor = BooksQuoteScreen.dict[chosenQuote]! as String

    // Assigns Quote & Author to IBOutlet

    Quote = chosenQuote
    Author = chosenAuthor


    quoteDisplay.text = Quote
    authorDisplay.text = Author.uppercaseString

}

我实际上在报价的背景上有一个计时器,它会在下午3点改变背景。我可以使用相同的元素来更改报价吗?提前致谢。如果您需要更多信息,请发表评论,我会立即更新。

0 个答案:

没有答案