swift - Compare two dates for Countdown Timer Swift2 -


i'm querying createdat column parse.

my parse methods above code , i'm doing this:

var createdat = object.createdat  if createdat != nil {      let twentyfourhours = nstimeinterval(60 * 60 * 24)     self.expiresat = nsdate(timeinterval: twentyfourhours, sincedate: (createdat!!))  } 

i querying many dates parse. however, i'm unable store them in createdat because createdat of type nsdate?.

i need make array, can't figure out how store many nsdate values can compare them.

how can store values i'm querying , put them array can compare many createdat dates nstimeinterval method using method: nsdate(timeinterval: twentyfourhours, sincedate: (createdat!!))?

am using correct function?

thanks in advance.

i guess easiest way store data double

let date = nsdate().timeintervalsince1970 let doubledate = double(date) 

create array, store , easy compare. when query it, do:

var date = nsdate(timeintervalsince1970: double(datedouble)) 

exemple:

    func exemple() {     // saving     // take date var array = [double]()      let datetosave = nsdate().timeintervalsince1970     let datetosave1 = nsdate().timeintervalsince1970     let datetosave2 = nsdate().timeintervalsince1970     let datetosave3 = nsdate().timeintervalsince1970     let datetosave4 = nsdate().timeintervalsince1970      array.append(double(datetosave))     array.append(double(datetosave1))     array.append(double(datetosave2))     array.append(double(datetosave3))     array.append(double(datetosave4))     print(array)     let objecttosave = pfobject(classname:"somedates")     objecttosave["dates"] = array     objecttosave.saveinbackgroundwithblock {         (success: bool, error: nserror?) -> void in         if (success) {             //done           } else {             // done != true :))         }     } } 

create column of type array

i test , works!


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -