2016-04-15 155 views
-5
let startDate=NSDate().dateByAddingTimeInterval(-60*60*24) 
let endDate=NSDate().dateByAddingTimeInterval(60*60*24*3) 

lblStart.text = i.startDate 

我想在標籤中顯示startdate。我如何將它轉換爲字符串。NSDate()轉換爲字符串

+0

http://stackoverflow.com/questions/28332946/nsdateformatter -stringfromdatensdate-returns-empty-string –

+0

http://www.appcoda.com/nsdate/ –

+0

可能的重複[轉換字符串到NSDate與Swift 2](http://stackoverflow.com/questions/33058091/convert-string -ns-nsdate-with-swift-2) – mgyky

回答

0

您可以嘗試lblStart.text = "\(i.startDate)"

要將變量轉換爲字符串或得到其數值輸出到標籤上,你會做到這一點:"\(variable name)"