How to invoke and inline block which is passed as function argument
How to invoke and inline block which is passed as function argument
- Subject: How to invoke and inline block which is passed as function argument
- From: ico <email@hidden>
- Date: Sat, 18 Sep 2010 03:32:23 +0800
Hi All,
I just wonder how to invoke an inline block which is passed as function
argument.
We can invoke a block if we declare a block as a variable, what if you
simply implement
them inline where they are required as an argument. It seems you have
nothing reference
to that block address.
For example, NSArray class has a method as follow:
- (NSArray *)sortedArrayUsingComparator:(NSComparator)*cmptr*
*
*
*the argument cmptr can simply be an inline block like:*
*[stringsArray sortedArrayUsingComparator:^(id string1, id string2) {*
* blah, blah;*
*}];*
*
*
*I just wonder inside the sortedArrayUsingComparator method, how to call
that block for*
*comparing two string since you don't have a reference to it. Another
example is qsort_b*
function. I just can't find the source code for those two methods.
Thanks for your help in advance.
--
==========================
Life isn't about finding yourself.
Life is about creating yourself.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden