ios - Get elements from array where date is today -


i have array of objects property date of type nsdate. array includes future days , past days.

i want array of elements array includes dates in today, not last 24 hours.

i ordered elements descending (new old):

alldashboards.sortinplace({ $0.date!.compare($1.date!) == nscomparisonresult.ordereddescending 

i tried loop, check if date yesterday , cut array there, doesn't work may no element yesterdays date:

    dash in alldashboards {          if (nscalendar.currentcalendar().isdateinyesterday(dash.date!)) {             print(i)             alldashboards.removerange(range.init(start: 0, end: i))             break         }          += 1     } 

is there method see if date past day instead of if date part of day?

one-liner:

let todaydashboards = alldashboards.filter { nscalendar.currentcalendar().isdateintoday($0.date!) } 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -