I've built up a test project with NSOperation and NSOperationQueue.
There is only one textbox: @property (weak) IBOutlet NSTextField *textbox;
In the background this is performed:
- (void)main
{
NSURL *url = [NSURL URLWithString:@"http://google.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog(@"MainThread: %@", ([NSThread isMainThread] ? @"YES" : @"NO"));
[[AppDelegate sharedManager] performSelectorOnMainThread:@selector(pageLoaded:)
withObject:response
waitUntilDone:NO];
}
And the selector that is called on the main thread:
- (void)pageLoaded:(NSString*)document
{
[textbox setStringValue:document]; // does nothing
NSLog(@"Textbox: %@", textbox); // returns nil
}
Why is textbox returning nil?