第一次来这里。我是swift的初学者(以及一般的编程),我正在尝试创建一个简单的应用程序,它将显示基于当天的5个时间值。我尝试了很多东西,但是这里不能开发逻辑。我将复制粘贴代码(其中一些是伪代码)。
import UIKit
class ViewController: UIViewController {
// TIME Values
let time1 = ["07:01", "07:03", "07:03"] // ..... Array continues for 365 days, every string value representing each day
let time2 = ["11:59", "11:59", "12:00"] // ..... Array continues for 365 days, every string value representing each day
let time3 = ["14:15", "14:16", "14:17"] // ..... Array continues for 365 days, every string value representing each day
let time4 = ["17:12", "17:13", "17:15"] // ..... Array continues for 365 days, every string value representing each day
let time5 = ["19:10", "19:11", "19:12"] // ..... Array continues for 365 days, every string value representing each day
// Current Date
let todaysDate = NSDate()
// Pseudocode to extract the value from time arrays...
choose a value from TIME Values based on todaysDate
print(time1) // single value from time1 array (converted from string to date/time value) based on todaysDate
print(time2) // single value from time1 array (converted from string to date/time value) based on todaysDate
print(time3) // single value from time1 array (converted from string to date/time value) based on todaysDate
print(time4) // single value from time1 array (converted from string to date/time value) based on todaysDate
print(time5) // single value from time1 array (converted from string to date/time value) based on todaysDate
// Final values should be NSDate (or similar) values, because of time manipulation
let timeCorrection1 = ["00:02", "00:03", "00:03"] // ..... Correction continues for 365 days, every string value representing each day
let timeCorrection2 = ["00:02", "00:03", "00:03"] // ..... Correction continues for 365 days, every string value representing each day
let timeCorrection3 = ["00:02", "00:03", "00:03"] // ..... Correction continues for 365 days, every string value representing each day
let timeCorrection4 = ["00:02", "00:03", "00:03"] // ..... Correction continues for 365 days, every string value representing each day
let timeCorrection5 = ["00:02", "00:03", "00:03"] // ..... Correction continues for 365 days, every string value representing each day
override func viewDidLoad() {
super.viewDidLoad()
}
}
所以我的想法是从一个基于currentdate的字符串数组中获取一个值,并以nsdate格式(MM:hh样式)获取它,以便稍后可以对其进行操作,因为我想从其他值中减去或添加值变量(即00:02)。
我希望我很清楚,非常感谢你!