Re: How to invoke and inline block which is passed as function argument
Re: How to invoke and inline block which is passed as function argument
- Subject: Re: How to invoke and inline block which is passed as function argument
- From: Dave DeLong <email@hidden>
- Date: Fri, 17 Sep 2010 20:16:27 -0600
It's only anonymous/inline to you. "sortedArrayUsingComparator:" is declared like this:
- (NSArray *)sortedArrayUsingComparator:(NSComparator)cmptr
This means that inside the implementation of this method, "cmptr" refers to the block, and will be invoked like this:
cmptr(object1, object2);
Dave
On Sep 17, 2010, at 8:07 PM, ico wrote:
> Hi Dave,
>
> I think you misunderstood me, if a block declared with a block variable reference to it, of
> course we can call it like we would with a function pointer. What I don't know how to invoke
> the block is the case which we don't even have a function pointer to it, this happens when
> we implement an inline block, such as:
>
> stringsArray sortedArrayUsingComparator:^(id string1, id string2) {
> blah, blah;
> }];
>
> inside the sortedArrayUsingComparator implementation, we have an argument which is a
> block, but in this case, that is an inline block, just block arguments are declared(string1 and
> string2), we don't have a block variable though. So inside the sortedArrayUsingComparator
> implementation, how we can invoke that block?
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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