ios - Sorting a Swift array of object by mixture of NSDate and String times -


i have array of objects has startdate property of type nsdate, , property of statetime, string.

the issue i'm have startdate considers month, day, , year, not time. i'm making nsdate endpoint return date in format: "2015-10-01t00:00:00.000z".

starttime represented string format of "8:00 am".

i'm bit lost on how convert nsdate object sort comparison.

i'm comfortable swift , can offer help.

thanks

you can use work around. first convert array string.

var dateformatter = nsdateformatter()  dateformatter.dateformat = "yyyy-mm-dd" //format style. browse online format fits needs.  var datestring = dateformatter.stringfromdate(startdate)  var completedate = datestring+ starttime dateformatter.dateformat = "yyyy-mm-dd hh:mm a" let date = dateformatter.datefromstring(completedate) 

then use date comparsion.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -