我正在开发一个应用程序,需要检查作业的截止日期.我想知道截止日期是否在下周内,如果是,则执行操作.
我能找到的大部分文档都在Objective-C中,我无法弄清楚如何在Swift中完成它.谢谢您的帮助!!
我想知道将文本文件读入字符串数组中最简单,最干净的是快速的.
文本文件:
line 1
line 2
line 3
line 4
Run Code Online (Sandbox Code Playgroud)
进入这样的数组:
var array = ["line 1","line 2","line 3","line 4"]
Run Code Online (Sandbox Code Playgroud)
我也想知道如何在这样的结构中做类似的事情:
Struct struct{
var name: String!
var email: String!
}
Run Code Online (Sandbox Code Playgroud)
所以拿一个文本文件并将其放入数组中的struct中.
谢谢您的帮助!
当按下"输入"按钮时,我需要从警报视图中的文本字段中获取文本.
func inputMsg() {
var points = ""
var outOf = ""
var alertController = UIAlertController(title: "Input View", message: "Please Input Your Grade", preferredStyle: UIAlertControllerStyle.Alert)
let actionCancle = UIAlertAction(title: "Cancle", style: UIAlertActionStyle.Cancel) { ACTION in
println("Cacle")
}
let actionInput = UIAlertAction(title: "Input", style: UIAlertActionStyle.Default) { ACTION in
println("Input")
println(points)
println(outOf)
}
alertController.addAction(actionCancle)
alertController.addAction(actionInput)
alertController.addTextFieldWithConfigurationHandler({(txtField: UITextField!) in
txtField.placeholder = "I got"
txtField.keyboardType = UIKeyboardType.NumberPad
points = txtField.text
})
alertController.addTextFieldWithConfigurationHandler({(txtField: UITextField!) in
txtField.placeholder = "Out Of"
txtField.keyboardType = UIKeyboardType.NumberPad
outOf = txtField.text …Run Code Online (Sandbox Code Playgroud)