ios - objective c error "No visible @interface for 'NSString' declares the selector 'timeIntervalSinceDate:'" -
sorry posting have been wrestling sometime, have been trying use timeintervalsincedate
but not behaving. m file:
#import "viewcontroller.h" @interface viewcontroller() @end @implementation viewcontroller //warning: method definition 'timeintervalsincedate:' not found -(ibaction) setbuttontapped:(id)sender { nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; nsstring *datetimestring = [dateformatter stringfromdate: datetimepicker.date ]; nslog( @"set button tapped : %@", datetimestring ); nsdate* currentdate = [nsdate date]; nstimeinterval secs = [datetimestring timeintervalsincedate:currentdate]; //error: no visible @interface 'nsstring' declares selector 'timeintervalsincedate:’ nslog(@"seconds %f", secs); [self schedulelocalnotificationwithdate: datetimepicker.date]; [self presentmessage:@"succesfully set!"]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
and h file:
#import <uikit/uikit.h> #import <avfoundation/avfoundation.h> @interface viewcontroller : uiviewcontroller <avaudioplayerdelegate> { iboutlet uidatepicker *datetimepicker; } - (nstimeinterval)timeintervalsincedate:datetimepicker; -(ibaction) setbuttontapped:(id)sender; @end
also method timeintervalsincedate
? couldn't find info on , i'm new want sure how work out myself.
thanks
your trying perform method of nsdate on nsstring object (datetimestring). convert nsdate format first , call 'timeintervalsincedate:' method on nsdate object.
refer post on how convert nsstring nsdate.
Comments
Post a Comment