Re: Inter-Application Communication in Cocoa ?
Re: Inter-Application Communication in Cocoa ?
- Subject: Re: Inter-Application Communication in Cocoa ?
- From: Paul Collins <email@hidden>
- Date: Fri, 13 Sep 2002 15:32:01 -0700
Thanks for the response David! Here's my code. The issue is that the
receiving process finds the "object" in the NSNotification to be nil
instead of the string that was sent.
Sender application:
#define kNotDialCommand @"com.gracion.DTdial"
- (IBAction)dialOrHang:(id)sender {
NSDistributedNotificationCenter *notiCenter =
[NSDistributedNotificationCenter defaultCenter];
NSString *objStr;
int i;
...
if ([[sender title] isEqualToString:@"Connect"]) {
//[notiCenter postNotificationName:kNotDialCommand
object:objStr];
[notiCenter postNotificationName:kNotDialCommand
object:@"hello"];
}
...
}
Receiver process (a Foundation tool launched from the terminal as root
(using sudo)):
- (id)init {
self = [super init];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(dialCmd:)
name:kNotDialCommand
object:nil
suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(hangupCmd:)
name:kNotHangupCommand
object:nil
suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
return self;
}
- (void)dialCmd:(NSNotification*)noti {
SYSLog(LOG_INFO,@"DIAG: pcontrol got dialCmd noti. object = -%@-",
[noti object]);
// logs "DIAG: pcontrol got dialCmd noti. object = -(null)-"
// gdb po [noti object] returns <nil> here
[self doDial:[noti object]];
}
_______________________________________________
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.