Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective-C iOS 6 delegate NSString query
    primarykey
    data
    text
    <p>I'm trying to use a delegate to pass a value from one VC to another. I think I'm am misunderstanding the way it is supposed to work.</p> <p>In my main ViewController.h I have this:</p> <pre><code>@protocol defaultLocationChoice &lt;NSObject&gt; - (NSString *) locChoice; @end </code></pre> <p>In both my PreferencesViewController.h and ChooseServerViewController.h I have <code>defaultLocationChoice</code> declared in the @interface section and the property assinged like so:</p> <pre><code>@property (nonatomic, assign) id &lt;defaultLocationChoice&gt; locationDelegate; </code></pre> <p>Both are synthesized also. </p> <p>When the user segues from PreferencesViewController to ChooseServerViewController the prepare for segue code is:</p> <pre><code>- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"toServerChoice"]) { ChooseServerViewController *viewController = (ChooseServerViewController *)segue.destinationViewController; viewController.locationDelegate = self; } } </code></pre> <p>When a cell choice is made in ChooseServerViewController I call:</p> <pre><code>[self locChoice]; </code></pre> <p>Which is:</p> <pre><code>- (NSString *) locChoice { NSLog(@"Cell Vale Loc choice %@",cellValue); return cellValue; } </code></pre> <p>The NSLog verifies the correct value is returned.</p> <p><strong>Now, as I think I understand it, the value of LocChoice in the delegate is now the value returned, no?</strong></p> <p>When the user goes back (NavController) the PreferencesViewController has:</p> <pre><code>-(void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; defaultLocation = [locationDelegate locChoice]; [self.tableView reloadData]; } </code></pre> <p>I was expecting the value of defaultLocation to now equal the value passed to locChoice. However when the table reloads the cell in question is still blank, implying what I exepct to happen isn't happening. </p> <p>Any ideas? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload