Very strange Xpc magic
Very strange Xpc magic
- Subject: Very strange Xpc magic
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 16 Sep 2013 15:22:01 +0700
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.
10.8.5
The latest and still very secret Xcode.
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