Passing ids to Distributed Objects
Passing ids to Distributed Objects
- Subject: Passing ids to Distributed Objects
- From: Nicolai <email@hidden>
- Date: Mon, 2 Dec 2002 09:30:07 +0100
Hi out there!
I want my app to become multithreaded, but there is a problem:
I have a window controller class and a class doing lengthy
calculation. During initialization of the controller class
I create two ports, make a connection, kick of a thread by
passing the ports to the thread and do the following:
+ (void)_connectWithPorts:(NSArray *)ports
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSConnection *connection = [NSConnection
connectionWithReceivePort:[ports objectAtIndex:0]
sendPort:[ports objectAtIndex:1]];
id rootProxy = (id)[connection rootProxy];
ThreadBase *thread = [[self alloc] initForParent:rootProxy];
[rootProxy setThreadAddress:thread]; //pass to controller object
(other side of connection)
[thread release];
[[NSRunLoop currentRunLoop] run];
[pool release];
}
Now it is possible to interact between the two object usings
functions declared by protocols.
But whenever I use a function which passes an id like
- (void)setPicture:(NSImage *)pImage; // id acts the same
the id received is invalid. I already made sure that the id
is not released yet.
I wonder how this works...
[rootProxy setThreadAddress:thread];
==>
- (void)setThreadAddress:(id)anObject
{
[anObject setProtocolForProxy:@protocol(ThreadMethods)];
[anObject retain];
[(id)_myThread release];
_myThread = (id <ThreadMethods>)anObject;
}
Does anyone know what I do wrong?
Greets, Nico.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.