小编Hen*_*ler的帖子

使用Swift进行NSDate比较

我正在开发一个应用程序,需要检查作业的截止日期.我想知道截止日期是否在下周内,如果是,则执行操作.
我能找到的大部分文档都在Objective-C中,我无法弄清楚如何在Swift中完成它.谢谢您的帮助!!

nsdate swift xcode6

150
推荐指数
8
解决办法
9万
查看次数

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中.

谢谢您的帮助!

string file swift

12
推荐指数
3
解决办法
1万
查看次数

Swift UIAlertController获取文本字段文本

当按下"输入"按钮时,我需要从警报视图中的文本字段中获取文本.

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)

xcode swift uialertcontroller

5
推荐指数
2
解决办法
5692
查看次数

标签 统计

swift ×3

file ×1

nsdate ×1

string ×1

uialertcontroller ×1

xcode ×1

xcode6 ×1