ios - passing data to UIView before its loaded onto the navigation controller -


i have complex situation (well me) trying resolve far having trouble it.

i outline structure of application , explain problem having. names using made due sensitivity of data using.

secondtolastviewcontroller // uitableview on navigation stack lastviewcontroller // normal uiview want push onto navigation stack requestclass // class dose requests database , passed data correct classes getinfoclass // class used specific request stores information correctly , passes secondtolastviewcontroller 

so user initiates didselectrowatindexpath inside secondtolastviewcontroller make request data using requestclass

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { //.. [requestclass getinfo:storedinfopram]; } 

now thread shoots off requestclass, in turn queries db data received , data passed off getinfoclass reason have done because there dozens , dozens of different calls in requestclass doing different things, particular request brings alot of data have sort correct object types have created class me.

anyway inside getinfoclass sort correct types etc , pass data back secondtolastviewcontroller in method called reciveddata, think things going wrong... create new instance of secondtolastviewcontroller thing dont know how pass data same secondtolastviewcontroller on stack , original request came from.

- (void) reciveddata { // stuff pass data secondtolastviewcontroller  secondtolastviewcontroller *sec = [[secondtolastviewcontroller alloc] init];      [sec sendgetseriesarrays:pram1 pram2:pram2 pram3:pram3 pram4:pram4 pram5:pram5];  } 

now going secondtolastviewcontroller thread lands in method

- (void)sendgetseriesarrays:pram1 pram2:pram2 pram3:pram3 pram4:pram4 pram5:pram5{      // call detailed view onto stack     lastviewcontroller *last = [[lastviewcontroller alloc] initwithnibname:@"lastviewcontroller" bundle:nil];      [self.navigationcontroller pushviewcontroller:last animated:yes]; } 

after thread reaches point nothing happens... data there , ready sent new view never pushed controller stack.. , think due me declaring version of secondtolastviewcontroller when inside getinfoclass

what know firstly how pass recived data in sendgetseriesarrays final view , secondly how load lastview onto navigation stack?

your observation correct creating secondtolastviewcontroller instance again inside getinfoclass. dont have use delegate/protocol approach passing data secondtolastviewcontroller.

do this
define protocol in getinfo class

getinfoclass.h

@protocol getinfoclassprotocol <nsobject>   //delegate method calling after getting data  // dont know argument types give   - (void)sendgetseriesarrays:pram1 pram2:pram2 pram3:pram3 pram4:pram4 pram5:pram5;   @end    // declare delegate property   @property (assign, nonatomic)id<getinfoclassprotocol>delegate; 

getinfoclass.m

- (void) reciveddata { // stuff pass data secondtolastviewcontroller     if ([self.delegate respondstoselector:@selector(sendgetseriesarrays: param2:)])    {      [self.delegate sendgetseriesarrays:pram1 pram2:pram2 pram3:pram3 pram4:pram4 pram5:pram5];   }   } 

secondtolastviewcontroller.m

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  //..  requestclass.delegate = self;  [requestclass getinfo:storedinfopram]; } 

your secondtolastviewcontroller should conform getinfoclassprotocol


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -