Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Delegation is the correct pattern to be used in this case, but your description doesn't look much like delegation as it is using a global variable. Perhaps you're storing global variables in your App Delegate which you should always try to avoid.</p> <p>Here's a rough outline of what the code should look like:</p> <p><strong>SecondViewController.h</strong>:</p> <pre><code>@protocol SecondViewControllerDelegate; @interface SecondViewController; SecondViewController : UIViewController { id&lt;SecondViewControllerDelegate&gt; delegate; NSArray* someArray; } @property (nonatomic, assign) id&lt;SecondViewControllerDelegate&gt; delegate; @property (nonatomic, retain) NSArray* someArray; @end @protocol SecondViewControllerDelegate - (void)secondViewControllerDidFinish:(SecondViewController*)secondViewController; @end </code></pre> <p><strong>SecondViewController.m</strong>:</p> <pre><code>@implementation SecondViewController @synthesize delegate; @synthesize someArray; - (void)dealloc { [someArray release]; [super dealloc]; } - (void)someMethodCalledWhenUserIsDone { [delegate secondViewControllerDidFinish:self]; } </code></pre> <p>FirstViewController.h:</p> <pre><code>#import SecondViewController @interface FirstViewController : UIViewController &lt;SecondViewControllerDelegate&gt; { ... } @end </code></pre> <p><strong>FirstViewController.m</strong>:</p> <pre><code>@implementation FirstViewController - (void)secondViewControllerDidFinish:(SecondViewController*)secondViewController { NSArray* someArray = secondViewController.someArray // Do something with the array } @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