On 04/07/2012, at 3:50 PM, Roland King wrote:

> Put 'NSComparisonResult' after = and before ^ to declare the return value of 
> the block in the code below. 


That didn't work, but after a few more wild guesses, I stumbled on the correct 
form:

        NSComparisonResult (^comp)( id<DKStorableObject>, id<DKStorableObject> 
) = ^NSComparisonResult( id<DKStorableObject> a, id<DKStorableObject> b )
        {
                if( a.index < b.index )
                        return NSOrderedAscending;
                else if ( a.index > b.index )
                        return NSOrderedDescending;
                else
                        return NSOrderedSame;
        };





> 
> When that fails. Err. Not sure. 


That's the trouble - when it doesn't work, even when you follow the examples in 
the documentation apparently to the letter, you're stuck.


On 04/07/2012, at 4:12 PM, Ken Thomases wrote:

> t follows the general form for C declarations, such as for function pointers. 
>  However, blocks can be defined in different contexts than functions, which 
> makes it seem out of place.  In general, try writing it exactly as though you 
> were writing a function.  Then replace the function name with either "^" or, 
> when defining a variable or typedef, "(^name_of_variable_or_typedef)".


OK, that's a handy bit of help. Mind you, function pointers themselves are not 
always that easy to get right, though I haven't run into anywhere near as much 
trouble with them as I have with blocks.

Thanks for all the advice,

--Graham



_______________________________________________

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

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

Reply via email to