iphone - Initialize a NSDate object with a specific time -
i have time in string format example 2:00. want initialize nsdate present date. tried doing
   nsdatecomponents *comps = [[nsdatecomponents alloc] init];    [comps sethour:2]; i not able compare date object. please help
try
nsdatecomponents *comps = [[nsdatecomponents alloc] init]; [comps setday:6]; [comps setmonth:5]; [comps setyear:2004];  nscalendar *gregorian = [[nscalendar alloc]     initwithcalendaridentifier:nsgregoriancalendar]; nsdate *date = [gregorian datefromcomponents:comps]; you should able compare date after that.
maybe mean like. think set using today's date , can create nsdatecomponents , set time values.
nsdate *today = [nsdate date]; nscalendar *gregorian = [[nscalendar alloc]                          initwithcalendaridentifier:nsgregoriancalendar]; nsdatecomponents *weekdaycomponents =                     [gregorian components:(nsdaycalendarunit | nsweekdaycalendarunit) fromdate:today]; [weekdaycomponents sethour:12]; [weekdaycomponents setminute:10]; [weekdaycomponents setseconds:30]; 
Comments
Post a Comment