• 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: Very strange Xpc magic
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very strange Xpc magic


  • Subject: Re: Very strange Xpc magic
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Mon, 16 Sep 2013 22:16:28 +0700

On 16 Sep 2013, at 22:10, Charles Srstka <email@hidden> wrote:

> On Sep 16, 2013, at 3:22 AM, Gerriet M. Denkmann <email@hidden> wrote:
>
>> In a new app (not document based) I inserted:
>>
>> #import "ZipProtocol.h"
>>
>> //	ZipProtocol.h:
>> @protocol ZipProtocol <NSObject>
>> - (void)command:(NSString *)command  withReply: (void (^)(  NSString *answerString ))reply;
>> @end
>>
>> #define MAGIC_BUG_REMOVAL 	//	defined or not - makes a strange difference
>>
>> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
>> {
>> 	NSString *helperName = @"something.very.silly";
>>
>> 	NSXPCConnection *aCo = 	[[NSXPCConnection alloc] 	initWithMachServiceName:	helperName
>> 														options: 	0
>> 							 ];
>> 	if ( aCo == nil)	//	error
>> 	{
>> 		NSLog(@"%s Error NSXPCConnection",__FUNCTION__);
>> 		return ;
>> 	};
>>
>> 	#ifdef MAGIC_BUG_REMOVAL
>> 		NSLog(@"%s will use magic - you will see MAGIC_ERROR",__FUNCTION__);
>> 	#else
>> 		NSLog(@"%s without magic  - you will NOT see MAGIC_ERROR",__FUNCTION__);
>> 	#endif
>>
>> 	aCo.remoteObjectInterface = [ NSXPCInterface interfaceWithProtocol: @protocol(ZipProtocol) ];
>> 	[ aCo resume];
>>
>> 	//	can do magic here
>>
>> 	id <ZipProtocol> ree;
>> 	ree =	[ aCo remoteObjectProxyWithErrorHandler: ^(NSError *err)
>> 				{
>> 					//	if helperName is not running (always the case) and
>> 					//	MAGIC_BUG_REMOVAL is NOT defined, then the next line will never print:
>> 					NSLog(@"%s MAGIC_ERROR: %@",__FUNCTION__, err);
>> 				}
>> 			];
>> 	if ( ree == nil)	//	error
>> 	{
>> 		NSLog(@"%s Error remoteObjectProxy",__FUNCTION__);
>> 		return;
>> 	};
>>
>> 	//	can do magic here as well:
>>
>> 	#ifdef MAGIC_BUG_REMOVAL
>> 		NSLog(@"%s will use magic",__FUNCTION__);
>> 	#endif
>>
>> 	[ ree	command: 	@"a command"
>> 			withReply:	^( NSString *answerString )
>> 			{
>> 				NSLog(@"%s the reply block %@",__FUNCTION__, answerString );
>> 				[ aCo invalidate];
>> 			}
>> 	];
>>
>> 	NSLog(@"%s did send",__FUNCTION__);
>> }
>>
>>
>> The question: why does the fact whether MAGIC_BUG_REMOVAL is defined or not makes any difference?
>> Seems not to depend on optimisation - same for Debug and Release builds.
>>
>> Probably there is a very simple answer, but I just cannot see it.
>
> What's the error that logs in your error handler?

If (and only if) MAGIC_BUG_REMOVAL is defined, I see:
 Error Domain=NSCocoaErrorDomain Code=4099 "Couldn’t communicate with a helper application."

Makes sense, as there just is no helper application named: "something.very.silly".


Kind regards,

Gerriet.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: Very strange Xpc magic
      • From: Charles Srstka <email@hidden>
References: 
 >Very strange Xpc magic (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Very strange Xpc magic
  • Next by Date: Re: Very strange Xpc magic
  • Previous by thread: Re: Very strange Xpc magic
  • Next by thread: Re: Very strange Xpc magic
  • Index(es):
    • Date
    • Thread