xcode5 - Pass integer between two view controllers -


what i'm trying accomplish pretty simple: passing integer between view controllers. i've looked @ ton of tutorials , thought had it, code seems need fixing.

viewcontroller1.h

int selectnumber;  @interface viewcontrollerincome : uiviewcontroller { iboutlet uilabel *inputnumber; }  -(void)setintval:(nsuinteger)inval; 

viewcontroller1.m

#import "viewcontroller2.h"  -(void)setintval:(nsuinteger)inval { _intval = inval; }  - (ibaction)enterbutton:(id)sender{  selectnumber = _intval;  } 

viewcontroller2.h

int incomenumber;  nsuinteger _intval;   @interface viewcontroller : uiviewcontroller  @property (weak, nonatomic) iboutlet uilabel *numberlabel; 

viewcontroller2.m

- (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib.  [nsstring stringwithformat:@"%d",_intval]; incomenumber = incomenumber + _intval;  numberlabel.text  = [nsstring stringwithformat:@"%i", incomenumber]; _intval = 0;   } 

as can see, goal take integer selectnumber, pass other view controller , add inputnumber, , display label numberlabel.

viewcontroller1 needs reference viewcontroller2. can set property of viewcontroller2.

your code looks little confusing. planning do? both viewcontrollers visible @ same time or planning pass value during navigation 1 other?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -