ios - Passing variables back to a ViewController using a Delegate does not work -


i found walk through of how pass string values viewcontroller calling viewcontroller , got working perfectly. example good.

https://www.youtube.com/watch?v=yvikeor3gyg

that said, technique passing content seems relatively straight forward have seen it, if it's not intuitive.

the example code includes 2 controllers. when replicated code using more detailed storyboard, code doesn't work. in test app, embedded calling controller inside navigationcontroller see whether have affect, still continued work fine.

in application, viewcontroller embedded within navigationcontroller called via swrevealcontroller segue class. don't know if important or relevant mentioning it.

i call collectionviewcontroller choose icon should passed calling viewcontroller.

when select icon, correctly identify icon , pop

- (void)collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath *)indexpath {     selectedicon = [placeicons objectatindex:indexpath.row];     nslog(@"in iconcollectionviewcontrolled - selected %@", selectedicon);      nsstring *itemtopassback = @"12345";      // testing old string here...  // [self.delegate passbackicon:selectedicon]; // commenting out while testing      [self.delegate passbackicon:itemtopassback];     [self.navigationcontroller popviewcontrolleranimated:yes]; } 

i correct trace suggesting right icon selected. expect text '12345' passed calling controller.

in calling controller, have following:

- (void)passbackicon:(nsstring *)iconname {     nslog(@"icon use %@", iconname); } 

but isn't being called @ (or @ least i'm not seeing nslog being shown. it's being ignored.

the delegate being correctly declared far can tell.

am missing something?

i suggest wrapping delegate in check see valid , has adopted respective method (if optional).

if(self.delegate && [self.delegate respondstoselector:@selector(passbackicon:)]){     [self.delegate passbackicon:itemtopassback]; }else{     nslog(@"your delegate not setup correctly"); } 

if enters else, have not set delegate properly..ie never did

self.delegate = someinstanceofaclassthatadoptsyourdelegate; 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -