incompatible pointer type sending NSString to parameter of type NSDate* _Nonnull ios Objective c -


i have following code. here tried 2 methods date , time. if use formatter gives me above error. if not use date format not correct , plus time incorrect. kindly help.

nsdate *pickuphourslate; nsdate *drophourslate;  formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"dd-mm-yyyy hh:mm"]; nslog(@"old date , time : %@",[formatter stringfromdate:[nsdate date]]); 

this give me output 12-07-2016 18:32 want

nscalendar *calender = [[nscalendar alloc] initwithcalendaridentifier:nscalendaridentifiergregorian];     nsdatecomponents *components = [[nsdatecomponents alloc] init];     int pickhourstoadd = [[[nsuserdefaults standarduserdefaults] objectforkey:@"pickuppriortimeperiod"] intvalue];     [components sethour:pickhourstoadd];     pickuphourslate = [calender datebyaddingcomponents:components todate:[formatter stringfromdate:[nsdate date]] options:0];     

this line gives me error

int drophourstoadd = [[[nsuserdefaults standarduserdefaults] objectforkey:@"droppriortimeperiod"] intvalue]; [components sethour:drophourstoadd]; drophourslate = [calender datebyaddingcomponents:components todate:[nsdate date] options:0];    

this line gives me value 2016-07-12 15:02:51 +0000 after adding 2 hrs current time here time incorrect

try this....

    nsdate *pickuphourslate; nsdate *drophourslate;  formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"dd-mm-yyyy hh:mm"]; [formatter settimezone:[nstimezone systemtimezone]]; nslog(@"old date , time : %@",[formatter stringfromdate:[nsdate date]]); **<this give me output 12-07-2016 18:32 want>** nscalendar *calender = [[nscalendar alloc] initwithcalendaridentifier:nscalendaridentifiergregorian]; nsdatecomponents *components = [[nsdatecomponents alloc] init]; int pickhourstoadd = [[[nsuserdefaults standarduserdefaults] objectforkey:@"pickuppriortimeperiod"] intvalue]; [components sethour:pickhourstoadd];  //editing start nsstring *datestr = [formatter stringfromdate:[nsdate date]] ; nsdate *date = [formatter datefromstring:datestr];     pickuphourslate = [calender datebyaddingcomponents:components todate: date options:0];    **<this line gives me error>** //editing  end  int drophourstoadd = [[[nsuserdefaults standarduserdefaults] objectforkey:@"droppriortimeperiod"] intvalue]; [components sethour:drophourstoadd]; drophourslate = [calender datebyaddingcomponents:components todate:[nsdate date] options:0];   **<this line gives me value "2016-07-12 15:02:51 +0000" after adding 2 hrs current time here time incorrect>** 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -