iphone - is it possible use temporary variable pass value -


i have temporary variable eneity , 2 viewcontroller:oneviewcontroller , secondviewcontroller.they jump each other fine.now use eneity send value oneviewcontroller secondviewcontroller.but when secondviewcontroller return value eneity, oneviewcontroller can't return value anymore.

i want know if can use variable return value ,instead of delegate?

thanks help;

add:

firstviewcontroller,example3viewcontroller:

#import "example3viewcontroller.h"  @interface example3viewcontroller ()  @end  @implementation example3viewcontroller @synthesize editorvc; @synthesize labelname; @synthesize labelnumber; @synthesize labelsummary; @synthesize b;  (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; }  (void)viewdidload { [super viewdidload]; // additional setup after loading view. //when iboutlet not used,use program makd connection editorviewcontroller* vc = [[editorviewcontroller alloc]initwithnibname:@"editorviewcontroller" bundle:nil]; self.editorvc = vc; vc = nil; }  (void)viewwillappear:(bool)animated{ nslog(@"%@",self.b.name); self.labelname.text = self.b.name; self.labelnumber.text = self.b.number; self.labelsummary.text = self.b.summary; }  (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. }  (ibaction)edit:(id)sender{ [self presentmodalviewcontroller:editorvc animated:yes]; }  @end 

secondeviewcontroller,editorviewcontroller:

#import "editorviewcontroller.h" #import "example3viewcontroller.h" #import "test.h"  @interface editorviewcontroller ()  @end  @implementation editorviewcontroller @synthesize vtitle; @synthesize number; @synthesize summary;  (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; }  (void)viewdidload { [super viewdidload]; // additional setup after loading view. }  (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. }  (ibaction)done:(id)sender{ //[[self parentviewcontroller]dismissmodalviewcontrolleranimated:yes]; //example3viewcontroller* e3v = [[example3viewcontroller alloc]init];]  //e3v.name = title.text; //e3v.number = number.text; //e3v.summary = summary.text; //[self dismissviewcontrolleranimated:yes completion:^(void){  //}]; test* t = [[test alloc]init]; t.name = self.vtitle.text; t.number = self.number.text; t.summary = self.summary.text; //[t setname:vtitle.text]; //[t setnumber:number.text]; //[t setsummary:summary.text]; example3viewcontroller* e3v = [[example3viewcontroller alloc] initwithnibname:@"example3viewcontroller" bundle:[nsbundle mainbundle]]; e3v.b = t;  [self dismissmodalviewcontrolleranimated:yes]; [t release]; [e3v release];  }  -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{ [vtitle resignfirstresponder]; [number resignfirstresponder]; [summary resignfirstresponder]; } @end 

temporary variable:

#import "test.h"  @implementation test @synthesize name; @synthesize number; @synthesize summary; @end 

you can't write

example3viewcontroller* e3v = [[example3viewcontroller alloc] initwithnibname:@"example3viewcontroller" bundle:[nsbundle mainbundle]]; e3v.b = t; 

this create object of class example3viewcontroller , assign t value object not object in stack.

you can either write

example3viewcontroller* e3v = [((appdelegate *)[appdelegate sharedinstance]).navigationcontroller.viewcontrollers objectatindex:[((appdelegate *)[appdelegate sharedinstance]).navigationcontroller.viewcontrollers count]-1]; 

or

you can assign example3viewcontroller variable in secondviewcontroller (say examplobj)and in viewdidload of example3viewcontroller write vc.examplobj = self.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -