samedi 4 juillet 2015

Sqlite - how to retrieve a DATETIME field in Swift?

I am trying to retrieve a DATETIME field called TIMESTAMP from an SQLite DB with the following code:

let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
var d1: NSDate  = NSDate()
if getData.dictLocations["TIMESTAMP"] != nil {    
    d1 = dateFormatter.dateFromString(getData.dictLocationsNames["TIMESTAMP"]!)!
    } else {
    dateCreatedLabel.text = "FAILED"
} 

The problem seems to stem from the fact that there are only two options for getData:

getData.dictLocation which is <String, Double> or
getData.dictLocationNames which is <String, String>

So how do I pull a date? Needless to say the sample code always displays, "FAILED".

Any ideas? I am using FMDB.

This replaces a similar question I asked earlier today, now deleted, that was too broad.

Aucun commentaire:

Enregistrer un commentaire