Just like you would with a function pointer:

- (void) executeBlock:(void(^)(NSString * param))block {
  block(@"Hello world!");
}

Cheers,

Dave

On Sep 17, 2010, at 1:32 PM, ico wrote:

> 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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
> 
> This email sent to davedel...@me.com

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to