Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I agree with Talha's comment for this and would not recommend using Notification Center. It would be best to create a new class that inherits from NSObject to handle the socket events, but you can also make it work using only the app delegate if you need to. To make it easy for you...</p> <p>Create a link from socket class to the view controller</p> <p>Define TableViewSocketEventsDelegate somewhere that both files can see. You can create a public Constants.h or something.</p> <pre><code>@protocol TableViewSocketEventsDelegate &lt;NSObject&gt; @required - (void) someSocketEvent:(int)statusCode; //TODO: Add callbacks that make sense here @end </code></pre> <p>Give the socket class (in your case the app delegate .h file) a reference to something that will ultimately handle the action (in your case the table view controller)</p> <pre><code>@property (nonatomic, assign) id&lt;TableViewSocketEventsDelegate&gt; socketDelegate; </code></pre> <p>And in the .m be sure to synthesize the socketDelegate and assign it to the appropriate view controller. </p> <p>Next tell the view controller that it can handle these delegate call backs.</p> <p>in .h:</p> <pre><code>ViewController : UITableViewController&lt;TableViewSocketEventsDelegate&gt; </code></pre> <p>in .m:</p> <pre><code>#pragma mark - TableViewSocketEventsDelegate - (void) someSocketEvent:(int)statusCode { NSLog(@"Some socket event happened %I", statusCode); } </code></pre> <p>Now all you have to do is alter your existing methods in the app delegate that deal with sockets to call the new methods</p> <pre><code>if (self.socketDelegate) { [self.socketDelegate someSocketEvent:2]; } </code></pre> <p>Does that make sens to you? I would also recommend making a base class for all of your tab view controllers if they all need to deal with this same delegate.</p> <p>Good luck!</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.
    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