FROM : Terry Smyth
DATE : Thu Jan 23 11:23:22 2003
Thanks Nico & Jake,
That did the trick. By casting to a uintptr_t I can now see my object
at the other end of the connection. Though I still don't understand why
my objects are not getting encoded and transferred as I had expected
(it seems at present just a pointer to the object is sent). This is
fine for now while I am communicating between threads in the same app.
Later, my worker thread will need to run on a separate machine, and I
will need a full DO implementation - hopefully once I've done that, I
will see my objects encoded and transferred across the connection.
Thanks for your help,
Terry
On Tuesday, January 21, 2003, at 08:12 pm, Nico wrote:
> Hi Terry!
>
> I also ran into this problem.
> The simplest way to solve that problem is to pass your
> object pointer castet to a uintptr_t.
> After received by the worker thread simply cast the
> pointer back.
> Make sure the object is still valid for the worker.
> Maybe you retain the object for the worker and the
> worker releases it.
>
> Hope that helps...
> Nico
>
> On Montag, Januar 20, 2003, at 07:05 Uhr, cocoa-dev-
> <email_removed> wrote:
>
>> Date: Mon, 20 Jan 2003 17:50:39 +0000
>> Subject: Sending object between threads.
>> From: Terry Smyth <terry.<email_removed>>
>> To: <email_removed>
>>
>> Hi,
>>
>> Following the example given in the Cocoa documentation "Forming
>> Connections Between Threads", I have implemented a separate thread in
>> my app to do some stuff, using NSConnection/NSPort to communicate
>> between the main thread and the worker thread. It all works, except
>> that I'm having trouble passing my own custom objects to and from the
>> worker thread (so I can't actually get my worker to do any useful
>> work!!). I can pass other cocoa objects (eg NSString) just fine, and
>> they appear intact at the other side of the connection. If I pass my
>> own object, I just get junk at the other end.
>>
>> Objects of my custom class conform to NSCoding, but my
>> encodeWithCoder:
>> and initWithCoder: methods never get called. Have I missed something
>> obvious here, or is it more likely a dumb coding bug? I'm going round
>> in circles reading the documentation, but can't see what I'm doing
>> wrong. Can anyone suggest what I might have missed, or where I can go
>> for further reading (better still, is there any sample code which does
>> this - I couldn't find any?)
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Thu Jan 23 11:23:22 2003
Thanks Nico & Jake,
That did the trick. By casting to a uintptr_t I can now see my object
at the other end of the connection. Though I still don't understand why
my objects are not getting encoded and transferred as I had expected
(it seems at present just a pointer to the object is sent). This is
fine for now while I am communicating between threads in the same app.
Later, my worker thread will need to run on a separate machine, and I
will need a full DO implementation - hopefully once I've done that, I
will see my objects encoded and transferred across the connection.
Thanks for your help,
Terry
On Tuesday, January 21, 2003, at 08:12 pm, Nico wrote:
> Hi Terry!
>
> I also ran into this problem.
> The simplest way to solve that problem is to pass your
> object pointer castet to a uintptr_t.
> After received by the worker thread simply cast the
> pointer back.
> Make sure the object is still valid for the worker.
> Maybe you retain the object for the worker and the
> worker releases it.
>
> Hope that helps...
> Nico
>
> On Montag, Januar 20, 2003, at 07:05 Uhr, cocoa-dev-
> <email_removed> wrote:
>
>> Date: Mon, 20 Jan 2003 17:50:39 +0000
>> Subject: Sending object between threads.
>> From: Terry Smyth <terry.<email_removed>>
>> To: <email_removed>
>>
>> Hi,
>>
>> Following the example given in the Cocoa documentation "Forming
>> Connections Between Threads", I have implemented a separate thread in
>> my app to do some stuff, using NSConnection/NSPort to communicate
>> between the main thread and the worker thread. It all works, except
>> that I'm having trouble passing my own custom objects to and from the
>> worker thread (so I can't actually get my worker to do any useful
>> work!!). I can pass other cocoa objects (eg NSString) just fine, and
>> they appear intact at the other side of the connection. If I pass my
>> own object, I just get junk at the other end.
>>
>> Objects of my custom class conform to NSCoding, but my
>> encodeWithCoder:
>> and initWithCoder: methods never get called. Have I missed something
>> obvious here, or is it more likely a dumb coding bug? I'm going round
>> in circles reading the documentation, but can't see what I'm doing
>> wrong. Can anyone suggest what I might have missed, or where I can go
>> for further reading (better still, is there any sample code which does
>> this - I couldn't find any?)
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Terry Smyth | Jan 20, 18:50 | |
| Jake A. Repp | Jan 20, 20:51 | |
| Nico | Jan 21, 21:12 | |
| Terry Smyth | Jan 23, 11:23 | |
| Jorge Monteiro | May 13, 03:46 |






Cocoa mail archive

