Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you do have some misunderstanding there</p> <p>protocol and delegates are something that is passed around. in other words somebody need to be receiver and somebody need to be the sender. in your case.<br> update your protocol to this</p> <pre><code>@protocol defaultLocationChoice &lt;NSObject&gt; - (void)locChoice:(NSString *)updateString; // the method from delegate and implementer must be exact @end </code></pre> <p>and set implement the protocol to ViewController as a receiver</p> <pre><code>@interface VCReceiver : UIViewController &lt;defaultLocationChoice&gt; </code></pre> <p>then later in VCReceiver</p> <pre><code>- (void)viewDidLoad { ChooseServerViewController *vcSender = [[ChooseServerViewController alloc] init]; [vcSender setLocationDelegate:self]; // this is like saying. i have implemented method from protocol in this file (self) } - (void)locChoice:(NSString *)updateString { // update the VCReceiver here // or access vcSender value // or use the updateString value } </code></pre> <p>then in <code>ChooseServerViewController locChoice:</code> method (the one from your example) replace with this one and call <code>[self updateChoice]</code> instead:</p> <pre><code>- (void)updateChoice { if ([self.locationDelegate respondsToSelector:@selector(locChoice:)]) { [self.locationDelegate locChoice:aStringToUpdate]; // this will call VCReceiver locChoice } </code></pre> <p>it does not have to return anything because it is actually calling the VCReceiver method to tell it that <code>ChooseServerViewController</code> got the value ready to be read.</p>
    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. 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