ios - objective c error "No visible @interface for 'NSString' declares the selector 'timeIntervalSinceDate:'" -


sorry posting have been wrestling sometime, have been trying use timeintervalsincedatebut 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.

converting nsstring nsdate (and again)


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -