ios - 'NSInvalidArgumentException', reason: '-[UINavigationController setMed:]: unrecognized selector sent to instance 0x746dda0' -
i making app people health conditions manage medication. have created modal add medication works , saves new medication using core data.
i trying allow people edit medication after has been saved. trying send managed object of medication "fibromappmedseditviewcontroller" , assign information in viewdidload method of class.
i keep getting error:
'nsinvalidargumentexception', reason: '-[uinavigationcontroller setmed:]: unrecognized selector sent instance 0x746dda0'
could tell me doing wrong?
relevant methods in fibromappmedslistviewcontroller.m
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { //selmed declared @ top of file nsmanagedobject *selmed; selmed = [self.meds objectatindex:indexpath.row]; nslog(@"selected med: %@",[selmed valueforkey:@"name"] ); uistoryboardsegue *seguestring = [nsstring stringwithformat:@"%@",@"editmeds"]; nslog(@"%@",seguestring); [self performseguewithidentifier:@"editmeds" sender:indexpath]; } -(void) prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{ nslog(@"%@",segue.destinationviewcontroller); nslog(@"%@",[selmed valueforkey:@"name"] ); fibromappmedseditviewcontroller *dest = segue.destinationviewcontroller; dest.med = selmed; }
the fibromappmedseditviewcontroller.h
#import <uikit/uikit.h> @interface fibromappmedseditviewcontroller : uitableviewcontroller - (ibaction)savechanges:(id)sender; - (ibaction)deletebtnpressed:(id)sender; - (ibaction)dosagechanged:(id)sender; - (ibaction)maxdosagechanged:(id)sender; - (ibaction)cancel:(id)sender; - (ibaction)typechanged:(id)sender; @property (weak, nonatomic) iboutlet uitextfield *tbname; @property (weak, nonatomic) iboutlet uitextfield *tbdose; @property (weak, nonatomic) iboutlet uitextfield *tbmaxdose; @property (weak, nonatomic) iboutlet uitextfield *tbtype; @property (weak, nonatomic) iboutlet uistepper *stepperdose; @property (weak, nonatomic) iboutlet uistepper *steppermaxdose; @property (weak, nonatomic) iboutlet uisegmentedcontrol *changemeasure; @property (strong, nonatomic) nsmanagedobject *med; @end
the fibromappmedseditviewcontroller.m - parts altered affect way controller loads
#import "fibromappmedseditviewcontroller.h" #import "fibromappappdelegate.h" #import <coredata/coredata.h> @interface fibromappmedseditviewcontroller () @end @implementation fibromappmedseditviewcontroller @synthesize tbname; @synthesize tbdose; @synthesize tbmaxdose; @synthesize tbtype; @synthesize med; double dose; double maxdose; - (void)viewdidload { [super viewdidload]; tbname.text = [med valueforkey:@"name"];//name string in model tbdose.text = [med valueforkey:@"dose"];//dose double in model tbmaxdose.text = [med valueforkey:@"maxdose"];//maxdose double in model tbtype.text = [med valueforkey:@"type"];//type string in model }
if need see else please ask.
also, using storyboards app.
it appears log, fibromappmedseditviewcontroller (which should start capital letter btw) embedded in navigation controller. need navigation controller's root view controller.
-(void) prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{ uinavigationcontroller *nav = segue.destinationviewcontroller; fibromappmedseditviewcontroller *dest = (fibromappmedseditviewcontroller *)nav.topviewcontroller; dest.med = selmed; }
Comments
Post a Comment