Article View: comp.lang.objective-c
Article #253Re: objc_msgSend(....
From: Scott Hess
Date: Wed, 06 Mar 1991 02:19
Date: Wed, 06 Mar 1991 02:19
41 lines
2096 bytes
2096 bytes
In article <1991Mar5.165819.27088@beach.csulb.edu> lewicki@beach.csulb.edu (Dave Lewicki) writes:
Objective-C on the Next uses the C function objc_Send() to do the
actual messaging. Next says to NEVER use this function in your own
code. However, I need to get a pointer to a message.
And? What does having to get a pointer to a message have to do with
objc_Send()? If you mean "pointer to a message" in terms of a method
specification (a SEL variable), just say [anObject perform:aSel].
If you mean in terms of a pointer to the actual function involved
(there is one back in there somewhere :-), here's a piece of example
code which will work on List's of objects guarenteed to contain
only on type of instance:
@implementation List (ListStuff)
- fastMakeObjectsPerform:(SEL)aSel
{
int i=[self count];
if( i)
{
IMP func=[[self objectAt:0] methodFor:aSel];
while( i--)
func( [self objectAt:i], aSel);
}
return self;
}
@end
If you are _really_ concerned about speed, there, then you could
also skip the objectAt: and count calls and go directly to the List
internals. Hey, there are all kinds of needs, right?
If I've either totally missed the point, or you need elaboration,
feel free to contact me via email. I am:
--
scott hess scott@gac.edu
Independent NeXT Developer GAC Undergrad
<I still speak for nobody>
"Tried anarchy, once. Found it had too many constraints . . ."
"I smoke the nose Lucifer . . . Bannana, banna."
Technical Details
Message-ID:
<SCOTT.91Mar5201931@erick.gac.edu>Path:
arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!news.cs.indiana.edu!msi.umn.edu!noc.MR.NET!gacvx2.gac.edu!gacvx2.gac.edu!scottReferences:
<1991Mar5.165819.27088@beach.csulb.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!news.cs.indiana.edu!msi.umn.edu!noc.MR.NET!gacvx2.gac.edu!gacvx2.gac.edu!scott From: scott@erick.gac.edu (Scott Hess) Newsgroups: comp.lang.objective-c Subject: Re: objc_msgSend(.... Message-ID: <SCOTT.91Mar5201931@erick.gac.edu> Date: 6 Mar 91 02:19:31 GMT References: <1991Mar5.165819.27088@beach.csulb.edu> Organization: Gustavus Adolphus College Lines: 41 Nntp-Posting-Host: 138.236.10.8 In-reply-to: lewicki@beach.csulb.edu's message of 5 Mar 91 16:58:19 GMTLines: 41