Reputation: 326
I have a runthis.h file where I have a label:
IBOutlet NSTextField *updateStatus;
Now in my runthis.m file, in a class called startTest I update this using
-(IBAction) startTest:(id)sender {
[updateStatus setStringValue:@"Testing"];
}
Now if I create an object for the runthis class in another file testing.m and then try this:
runthis *testSomething = [[runthis alloc] init];
[testSomething performSelectorInBackground:@selector(startTest:) withObject:nil];
But I find the UI for the label *updateStatus will never get set to "Testing" when I call it from testing.m If I call this directly from runthis.m, then the UI gets updated as expected. Any ideas why ? Thanks.
Upvotes: 0
Views: 233
Reputation: 7272
Unless runthis
is located in a separate nib, it's outlet won't be connected automatically, you'll have to pass it as a reference. In testing
you'll have to wire up the text field, then pass it to runthis
like:
[testSomething setStatusField:updateStatus];
Or you could create a reference to your testing
object from your runthis
object (call it a delegate) and have testing
update the UI directly. That's the approach I would use.
Upvotes: 1