ios - Error with segue: 'NSInvalidArgumentException', reason: 'Receiver has no segue with identifier -
i'm getting error app: terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'receiver (<viewcontroller: 0x17e60c10>) has no segue identifier 'datetimestring''
. code this:
viewcontroller.m
-(ibaction) alarmsetbuttontapped:(id)sender { nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; dateformatter.timezone = [nstimezone defaulttimezone]; [dateformatter setdateformat:@"dd:mm:yyyy:ss:mm:hh"]; nsstring *datetimestring = [dateformatter stringfromdate: datetimepicker.date ]; nslog( @"alarm set : %@", datetimestring ); nsdateformatter *dateformatter1 = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"dd:mm:yyyy:ss:mm:hh"]; nsdate *datetimeseconds = [[nsdate alloc] init]; datetimeseconds = [dateformatter1 datefromstring:datetimestring]; nstimeinterval seconds = [[nsdate date] timeintervalsincedate:datetimepicker.date]; nslog(@"seconds %.f", seconds); nsstring *path = [nsstring stringwithformat:@"%@/alarm-clock.m4a", [[nsbundle mainbundle] resourcepath]]; nsurl *soundurl = [nsurl fileurlwithpath:path]; _alarmplayer = [[avaudioplayer alloc] initwithcontentsofurl:soundurl error:nil]; [_alarmplayer playattime: _alarmplayer.devicecurrenttime + seconds]; nslog( @"alarm set button tapped : %@", datetimestring ); [self schedulelocalnotificationwithdate: datetimepicker.date]; [self performseguewithidentifier:@"datetimestringsegue" sender: nil]; [self presentmessage:(@"alarm succesfully set %@",datetimestring)]; } -(ibaction)alarmcancelbuttontapped:(id)sender { nslog( @"alarm cancel button tapped"); [[uiapplication sharedapplication] cancelalllocalnotifications]; [self presentmessage:@"alarm canceled lazy pants!"]; } - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { viewcontroller3 *tvc = segue.destinationviewcontroller; nslog(@"prepareforsegue: %@", segue.identifier); if ([[segue identifier] isequaltostring:@"datetimestringsegue"]) { tvc.datetimestring = (@"%@",_datetimestring); nslog(@"segue"); } }
viewcontroller.h
@interface viewcontroller : uiviewcontroller <avaudioplayerdelegate> { iboutlet uidatepicker *datetimepicker; } @property nsinteger numberofloops; @property(readonly) nstimeinterval devicecurrenttime; @property (strong, nonatomic) avaudioplayer *alarmplayer; @property (strong, nonatomic) nsstring *datetimestring; - (nstimeinterval)timeintervalsincedate:datetimepicker; -(void) presentmessage: (nsstring *) message; -(void) schedulelocalnotificationwithdate: (nsdate *) firedate; -(ibaction) alarmsetbuttontapped:(id)sender; -(ibaction) alarmcancelbuttontapped:(id)sender; - (bool)playattime:(nstimeinterval)time; @end
seguedestination.h
#import "viewcontroller.h" @interface viewcontroller3 : uiviewcontroller @property(nonatomic, readonly) nsuinteger tapcount; @property nsinteger numberofloops; @property(readonly) nstimeinterval devicecurrenttime; @property (strong, nonatomic) avaudioplayer *alarmplayer; @property (strong, nonatomic) nsstring *datetimestring; @property (strong, nonatomic) iboutlet uilabel *datetimepicker; - (nstimeinterval)timeintervalsincedate:datetimepicker; - (bool)playattime:(nstimeinterval)time; - (ibaction)iconsbtn:(id)sender; @end
seguedestination.m
#import "viewcontroller.h" @interface viewcontroller3 () { avaudioplayer *_alarmplayer; } @end @implementation viewcontroller3 - (void)viewdidload { [super viewdidload] self.view.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"wwv5.jpg"]]; } - (void) buttontouchdownrepeat:(id)sender event:(uievent *)event { uitouch *touch = [[event alltouches] anyobject]; if(touch.tapcount == 3) { nslog(@"twice"); } else nslog(@"ughhhhh"); } - (ibaction)iconsbtn:(id)sender { }
i'm trying access datetimestring
in 2nd viewcontroller
whenever click button supposed send app terminates error. first time i've attempted use segue , i'm not going great it. once error sorted able call datetimestring
in 2nd viewcontroller
and value set in 1st viewcontroller
?
thanks!
edit: have done identifier in storyboard.
Comments
Post a Comment