Swift 的 Date 也會用數字計算時間 !

身為人類的我們,很會計算時間,比方現在是 11:04 ,一分鐘後是 11:05,因為 4 + 1 會變成 5。

Swift 的 Date,想不到也跟人類一樣聰明,也會用數字計算時間,只是它的單位是秒,如下圖所示,只要加上 60,即可計算一分鐘後的時間。減去 60,即可計算一分鐘前的時間。

彼得潘的 Swift iOS App 開發問題解答集

彼得潘和學生們在開發 iOS App 路上曾經解決的問題集

    彼得潘的 iOS App Neverland

    Written by

    彼得潘的 Swift 程式設計入門,App程式設計入門作者,彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,http://apppeterpan.strikingly.com

    彼得潘的 Swift iOS App 開發問題解答集

    彼得潘和學生們在開發 iOS App 路上曾經解決的問題集

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade