objective c - Syntax error trying to set a property value -
i want pass id
table view (tableviewcontroller
) view (viewcontroller
) after tap table cell. have declared storyboard id "viewcontroller" viewcontroller
here tableviewcontroller.m
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { uistoryboard *storyboard = [uistoryboard storyboardwithname:@"mainstoryboard" bundle: nil]; uiviewcontroller *viewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"viewcontroller"]; viewcontroller.id=@"test"; [self.navigationcontroller pushviewcontroller:viewcontroller animated:yes]; }
here viewcontroller.h
@property (nonatomic) nsstring *id;
viewcontroller.m
- (void)viewdidload{ id= [[nsstring alloc] init]; }
but statement viewcontroller.id=@"test";
occurred syntax error.
id
reserved word in objective-c. not name variable or property id
. rename else.
also, viewcontroller
variable declared uiviewcontroller
. there no id
property in uiviewcontroller
. change type of viewcontroller
actual type (viewcontroller
?).
viewcontroller *viewcontroller = (viewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"viewcontroller"];
Comments
Post a Comment