Jump to content

Access IBOutlet object from different thread


1 post in this topic

Recommended Posts

Hi,

 

I'm quite new to mac development but have done quite well in my sample project. I'm creating a Python-Objective-C project. I have one controller class that handles graphics objects I have created in interface builder. Everything has worked as excepted except one problem that I can't currently figure out by myself.

 

My application has UI thread and it has worker thread. The controller works as excepted when methods are called from the UI thread but if I try to call webview object through an IBOutlet from worker thread nothing happens. I get no error messages but it won't change the address of the webview. If I test the same command in UI thread it works. However I can't move the command to the UI thread because I need the input from the worker thread before I can call this method.

 

The code I use to change the view on webview component:

self.webView.mainFrame().loadRequest_(NSURLRequest.requestWithURL_(NSURL.URLWithString_(url)))

 

I have registered webview as follows:

webView = objc.IBOutlet("webView")

 

I also tried to create a new controller for webview and registered that in interface builder and set outlets to refer to that controller but when I create an object from that class it doesn't initialize the webview object. I get None value for it. Below is the code for the controller I tried to use for webview:

from Foundation import *
from CoreData import *
from AppKit import *
from AddressBook import *
from WebKit import *
from AppStarter import *

class WebViewHandler(NSObject):
webView = objc.IBOutlet("webView") # this is None even after calling init() method
def init(self):
	self = super(WebViewHandler, self).init()
	if self == None:
		NSLog("Error initializing web view handler")
		return None

	NSLog("web view handler init OK")

	return self

 

I was wondering if anyone has any pointers how to solve this problem?

Link to comment
Share on other sites

 Share

×
×
  • Create New...