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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -