Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I followed your code properly, you do not need to adopt the mentioned protocol in your <code>ChooseServerViewController</code>, only <code>PreferencesViewController</code>.</p> <p>The reasoning is you want to send data <strong>back</strong> to the previous view controller. Try:</p> <pre><code>@protocol defaultLocationChoice &lt;NSObject&gt; - (void) locChoice:(NSString*)choice; @end </code></pre> <p>Have your <code>PreferencesViewController</code> implement that method so it <strong>receives</strong> the selection. You will have to store that in an appropriate instance variable.</p> <pre><code>// in PreferencesViewController.m -(void)locChoice:(NSString*)choice { self.choice = choice; // this just my example } </code></pre> <p>When the choice is made (in <code>ChooseServerViewController</code>) to send the choice back, call:</p> <pre><code>// this is in 'ChooseServerViewController.m' some where appropriate [self.delegate locChoice:cellValue]; </code></pre> <p>Your implementation is simply doing nothing with cell value (not even storing it, just logging it). When you return to <code>PreferencesViewController</code>, you will now have the selected value and that view controller can what it wants with it.</p> <p>Protocols are somewhat analgous to interfaces in Java or C#, but more flexible.</p> <ul> <li><a href="http://developer.apple.com/library/ios/#documentation/General/Conceptual/CocoaEncyclopedia/DelegatesandDataSources/DelegatesandDataSources.html" rel="nofollow">Some more concepts about delegation</a>.</li> <li><a href="http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/WorkingwithProtocols/WorkingwithProtocols.html" rel="nofollow">Working with Protocols</a>.</li> </ul> <p><strong>UPDATE</strong>:</p> <p>The declaration for <code>ChooseServerViewController</code> should look like:</p> <pre><code>#import "FileWithProtocolDecalration.h" @interface ChooseServerViewController . . . @property ( nonatomic,assign) id&lt;defaultLocationChoice&gt; delegate; . . . @end </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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