Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have 2 options:</p> <ol> <li>Implement a delegate protocol</li> <li>Use NSNotifications</li> </ol> <p>The advantages/disadvantages of each is set out well in this question and answer: <a href="https://stackoverflow.com/questions/2232694/delegates-vs-notifications-in-iphoneos">Delegates v Notifications</a></p> <p>As notifications are easier to implement and may well be sufficient for your needs, you can implement it with the following steps:</p> <ol> <li>In the class where you download the data: When the data has been downloaded and the array populated, include the following lines:</li> </ol> <p><code>NSDictionary *dict = [NSDictionary dictionaryWithObject:array forKey:@"Data"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"DataDownloaded" object:self userInfo:dict];</code></p> <ol start="2"> <li>In the class where you want to receive the data:</li> </ol> <p>2.1 Add the following line to your viewDidLoad method:</p> <pre><code>`[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataDownloaded:) name:@"DataDownloaded" object:nil]; </code></pre> <p>2.2 Create the dataDownloaded selector:</p> <ul> <li><p>(void)dataDownloaded:(NSNotification *)note {</p> <p><code>NSDictionary *dict = note.userInfo; NSArray *dataArray = [note.userInfo objectForKey:@"DataDownloaded"];</code></p></li> </ul> <p>2.3 Add the following line to dealloc and viewDidUnload:</p> <pre><code>[[[NSNotificationCenter defaultCenter] removeObserver:self]; </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