• 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
Passing autoreleased objects in Distributed Object calls?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passing autoreleased objects in Distributed Object calls?


  • Subject: Passing autoreleased objects in Distributed Object calls?
  • From: Dave Fayram <email@hidden>
  • Date: Sun, 8 Sep 2002 21:24:35 -0700

Hi, I was wondering what to do when I have autoreleased objects and I'd
like to pass them through a
distributed objects call. It seems like this would be a common problem
but it doesn't seem to mention
it in the Distributed Objects docs.

If _reporter is my DO reference, when I do something like this:
srcHost = [NSHost hostWithAddress:[NSString stringWithFormat:@"%s",
opresentation]];
dstHost = [NSHost hostWithAddress:[NSString stringWithFormat:@"%s",
presentation]];
dPacket = [NSData dataWithBytes:packet length:header.caplen];
if( _reporter )
[_reporter packetFoundWithData:dPacket from:srcHost
to:dstHost];

Then in the other thread I want tofor testing purposessimply print
them out, I try:
// Protocol
-(oneway void)packetFoundWithData:(NSData *)packet from:(NSHost
*)source to:(NSHost *)destination {
[source retain];
[destination retain];
NSLog( @"--- PACKET FOUND \n\nFROM %@ \n\nTO %@", [source
autorelease], [destination autorelease]);
}

However, on that NSLog line I get an EXEC_BAD_ACCESS (sigbus). The call
stack shows a call to NSLog, then to NSPopAutoreleasePool, then
[NSInvocation dealloc], then [NSInvocation invalidate]. What exactly is
happening here? I thought the DO framework took care of these issues as
it passed things around.

I would just use non-autoreleased objects, but I can't do that. NSHost
doesn't seem to have an initWithAddress method, and NSHost doesn't
respond to -copyWithZone.

What should I do? Thanks for any help you can give, and your time.


- Dave Fayram
Freelance Coder / UCSB Student / Idealist
"Not everyone finds Drag'N'Drop as intuitive as they should."
_______________________________________________
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.

  • Prev by Date: [Ann] ObjCServices
  • Next by Date: Cocoa Sprite Kit question
  • Previous by thread: Re: [Ann] ObjCServices
  • Next by thread: Cocoa Sprite Kit question
  • Index(es):
    • Date
    • Thread