Note that there are some explanatory texts on larger screens.

plurals
  1. POView not updating when a message is sent to its view controller
    primarykey
    data
    text
    <p>I am having problems updating a view when a message from another class is sent to a <code>ViewController</code>.</p> <p>Basically I have an application with a single window where different custom views will be swapped out for another. I have an <code>AppController</code> Class that manages this and works fine:</p> <pre><code>@interface AppController : NSObject @property (weak) IBOutlet NSView *ourView; @property (strong) NSViewController *ourViewController; - (IBAction)changeView:(id)sender; - (IBAction)start:(id)sender; - (void)changeViewContoller:(NSInteger)tag; @end </code></pre> <p>When a new view is swapped out for another, the <code>ourViewController</code> property will be updated to point to that view's controller class. Every view controller class will have a method all named the same thing, for example "action". This method is supposed to change something on a view.</p> <p>So the "start" method in <code>AppController</code> class will then call the "action" method on the <code>ourViewController</code> property. To do this I used the <code>objc_msgSend()</code> method:</p> <pre><code>objc_msgSend(self.ourViewController, action); </code></pre> <p>Here's the View Controller class definition:</p> <pre><code>@interface CountdownViewController : NSViewController @property (weak) IBOutlet NSTextField *label; - (IBAction)changeLabel:(id)sender; - (void)start; @end </code></pre> <p>I placed an <code>NSLog()</code> in the "action" method for each <code>ViewController</code>, to see if it was working, and it does, however the "action" method is also supposed to change a label's string value, but it does not. If anyone knows why the view is not being updated, that would be extremely helpful. Thanks!</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.
 

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