ios - cannot invoke 'stringFromDate' error in swift -
i'm trying simple date format in swift i'm getting following error:
"cannot invoke 'stringfromdate' argument list of type '(nsdate?!)'"
my code follows:
override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! uitableviewcell // configure cell... let dateformatter = nsdateformatter() dateformatter.dateformat = ("dd-mmm-yyyy") var myusers: anyobject = users[indexpath.row] let strdate = dateformatter.stringfromdate(myusers.createdat) return cell }
}
does know why can't in swift? have used method before , worked fine. have searched other answers haven't found suitable.
appreciate available. many thanks
check following code:
var dateformatter = nsdateformatter() dateformatter.dateformat = "yyyy-mm-dd" let d = nsdate() let s = dateformatter.stringfromdate(d) println(s)
Comments
Post a Comment