• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: remote proxy object somehow not correct
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: remote proxy object somehow not correct


  • Subject: Re: remote proxy object somehow not correct
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Mon, 15 Jan 2007 19:29:58 -0800


On Jan 15, 2007, at 16:31, William Zumwalt wrote:

I'm still trying to get this one fixed, but I can't see where I've
gone wrong. I have a problem in the code below where I try to set an
instance of the thread in my parent thread, but for some reason, it
won't get called. I feel like the workers proxy object is not working
correctly.

[...]


	NSPort *port1 = [NSPort port];
	NSPort *port2 = [NSPort port];

	NSConnection *connection = [[NSConnection alloc]
		initWithReceivePort:port1 sendPort:port2];
	[connection setRootObject:controller];

	portArray = [NSArray arrayWithObjects:port2, port1,
		[NSNumber numberWithInt:tag], nil];

[...]

	serverConnection = [NSConnection
		connectionWithReceivePort:[portArray objectAtIndex:0]
		sendPort:[portArray objectAtIndex:1]];

I think you want to reverse these ports. You may also have some memory management issues to work out, since +startNetworkThreadWithTag returns a retained instance.


	int serverTag = [[portArray objectAtIndex:2] intValue];

	serverObject = [[NetworkServer alloc] initWithTag:serverTag];
	[serverConnection setRootObject:serverObject];

	// This call seems to be blocking here. Just hangs.
	[(id <NetworkController>)[serverConnection rootProxy]
		setServer:serverObject tag:serverTag];

Generally, you should wrap -[NSConnection rootProxy] in an exception handler and catch possible timeouts or other exceptions, as shown in the documentation. It's not really clear what you're doing, other than that. You're sending [[serverConnection rootProxy] setServer:tag:] on your worker thread, and using class objects as root objects. This final line is equivalent to just doing [serverObject setServer:serverObject tag:serverTag], which is probably not what you want.


If you're just getting started with DO, I'd recommend trying a really trivial example, since the documentation is pretty thin.

regards,
Adam

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: remote proxy object somehow not correct
      • From: "William Zumwalt" <email@hidden>
References: 
 >remote proxy object somehow not correct (From: "William Zumwalt" <email@hidden>)

  • Prev by Date: Re: NSString coding errors
  • Next by Date: Re: remote proxy object somehow not correct
  • Previous by thread: remote proxy object somehow not correct
  • Next by thread: Re: remote proxy object somehow not correct
  • Index(es):
    • Date
    • Thread