• 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: How To Design A Queue of Messages?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How To Design A Queue of Messages?


  • Subject: Re: How To Design A Queue of Messages?
  • From: Frode <email@hidden>
  • Date: Sat, 10 Sep 2005 21:26:42 +0200

Hello!

2005-09-10 kl. 20.10 skrev Andreas Mayer:

Am 10.09.2005 um 19:34 Uhr schrieb Frode:

I would use objc_sendMsg().

Any reason for not simply using performSelector:?

Does it really matter in this case?



- (id)initWithObjectAndSelector:(id)object selector:sel {
self = [super init];
_receiver = [object class];
if ([object respondsToSelector:sel]) {
// it would be reasonable to check that object implement selector HERE, // instead of in the loop sendMessages below...
[self dealloc];
return nil;
}
_sel = sel;
return self;
}

This seems wrong. If you want to send a message to 'object' later, it is no use storing [object class] only; you will have to store 'object'.

Yes, of course. This was for static messages and not object messages. It should be _receiver = object


In fact, we should actually write _receiver = [object retain]. Retaining and releasing the target object might be needed if the queue (or in our case, sendMessages:) is later calling object's message outside the scope of present auto-release pool used when allocating a ReceiverSelectorPair-object, which is often the case. Thus, we have:

- (id)initWithObjectAndSelector:(id)object selector:sel {
	if (!object || ![object respondsToSelector:sel]) {
		// nothing to do
		[self dealloc];
		return nil;
	}
	_receiver = [object retain];
	_sel = sel;
	return self;
}

- (void)dealloc {
	if (_receiver) [_receiver release];
}


Hope this helps.

Regards,
Roger P.

_______________________________________________
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: How To Design A Queue of Messages?
      • From: j o a r <email@hidden>
References: 
 >How To Design A Queue of Messages? (From: Jerry Krinock <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Andreas Mayer <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Frode <email@hidden>)
 >Re: How To Design A Queue of Messages? (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Geospatial processing using Cocoa libs (esp. Shapefile)
  • Next by Date: Re: How To Design A Queue of Messages?
  • Previous by thread: Re: How To Design A Queue of Messages?
  • Next by thread: Re: How To Design A Queue of Messages?
  • Index(es):
    • Date
    • Thread