Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edit: As Maddy mentioned in the comments the original posters code would have worked if it was just called after the viewController had gotten all of its view objects. The easy way to achieve what the original poster wanted would be to simply add:</p> <pre><code>self.test.text = @"test"; </code></pre> <p>to the viewControllers viewDidLoad method.</p> <p>I'll leave my original answer here anyway, as I believe it improves on the original posters code and removes some of its dependencies. It still is way too complicated for what it wants to achieve but the pattern as such could be transferred to more befitting scenarios:</p> <hr> <p>To elaborate on my comment:</p> <p>Your method</p> <pre><code>+ (void)getSchedule{ NSLog(@"log"); FirstViewController *VC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; VC.test.text = @"test"; } </code></pre> <p>Is a class method. So, naturally it is fired, but your UILabel instance test this instance have no idea about this. Furthermore you seem to have created your own class Label which subclasses NSObject, but the actual label instance is a regular UILabel.</p> <p>I would guess what you are trying to do is something like this:</p> <pre><code>@interface Label : UILabel - (void)getSchedule; @end </code></pre> <p>... </p> <pre><code>@interface FirstViewController : UIViewController @property (nonatomic, retain) IBOutlet Label *test; </code></pre> <p>Edit: forgot the method(!)</p> <pre><code>- (void)getSchedule{ self.text = @"test"; } </code></pre> <p>And finally in your viewController... </p> <pre><code>#import "Label.h" -(IBAction)refresh:(id)sender { [self.test getSchedule]; } </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. 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