为照片上传添加时间戳

时间:2015-07-30 16:13:02

标签: ios image timestamp

我正在将我的iOS应用中的照片上传到我的服务器。目前我正在编写我正在上传的照片的名称,但这会导致所有后续照片被覆盖(自然)。为了解决这个问题,我想为图像创建一个新名称,最好是添加一个标题(我在一个单独的文本字段中定义)以及上传时间戳。我对此代码的尝试如下,但它们不起作用:P ...

CMP &ALPHA,&BETA
IFEQ 2,2         ; Execute the first and second instructions if ALPHA = BETA
                 ; or the third and fourth instructions if ALPHA  BETA
MOV #0,&ALPHA    ; Executed if ALPHA = BETA
MOV #1,&BETA     ; Executed if ALPHA = BETA
MOV &BETA,&ALPHA ; Executed if ALPHA ≠ BETA
ADD #1,&ALPHA    ; Executed if ALPHA ≠ BETA

1 个答案:

答案 0 :(得分:3)

类似

var currentTimeStamp = String(Int(NSDate().timeIntervalSince1970))

还可以添加

extension Double {
    func format(f: String) -> String {
        return NSString(format: "%\(f)f", self) as String
    }

    func toString() -> String {
        return String(format: "%.1f",self)
    }

    func toInt() -> Int{
        var temp:Int64 = Int64(self)
        return Int(temp)
    }
}

var currentTimeStamp = NSDate().timeIntervalSince1970.toString()

编辑:文件名

let filename = "\(header)_\(currentTimeStamp)_img.jpg"