• 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
NSMessagePort crashes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMessagePort crashes


  • Subject: NSMessagePort crashes
  • From: Stephan Lichtenauer <email@hidden>
  • Date: Sun, 23 Jan 2005 17:15:52 +0100

Hi all,

I have written a small test program to use NSMessagePorts/NSPortMessages but at best the message is not received and in the worst case the program crashes with a EXC_BAD_ACCESS.

Below is my code, when I initialize the message as it can be seen with the distantPort, the app crashes, when I init. it with a send port of nil it does not crash but the message is not received nevertheless (push is attached to a button in the IB)... I looked everywhere on the net and in my "Core Mac OS X and Unix Programming" and Cocoa books and could not find much example code that would help, all the code I found looked more or less what I did...

@implementation Test

-(id)init {
[super init];


localPort = [[NSMessagePort alloc] init];
[localPort setDelegate:self]; // do I need this?
distantPort = [[NSMessagePort alloc] init];


[[NSRunLoop currentRunLoop] addPort:localPort forMode:NSDefaultRunLoopMode];

return self;
}

- (void)handlePortMessage:(NSPortMessage *)portMessage {
NSLog(@"Msg received");
}

-(id)sender {
NSPortMessage *msg;
msg = [[NSPortMessage alloc] initWithSendPort:distantPort
receivePort:localPort

components:nil];
[msg setMsgid:10];
[msg sendBeforeDate:[NSDate distantPast]];
}


@end

Anybody any idea?

Thanks a lot!

Stephan

PS I know there are memory leaks but I wanted to keep the code as simple as possible...
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSMessagePort crashes
      • From: Gwynne <email@hidden>
  • Prev by Date: Re: [OT] Software Delivery (was Re: Why do "loose" nibs take precedence over nibs in .lproj?)
  • Next by Date: Re: XCode: generate KVC compliant method bodies from header
  • Previous by thread: NSTableView header text slows down
  • Next by thread: Re: NSMessagePort crashes
  • Index(es):
    • Date
    • Thread