On 18 Jun 2018, at 16:49, amon <[email protected]> wrote: > > So you are saying this would be good to go? > > NSUInteger i; > NSMutableArray *a; > NSEnumerationOptions opts; > GSPredicateBlock predicate = ^() { return YES; } > > i = [a indexOfObjectWithOptions: opts passingTest: predicate];
No, because that block does not take the correct number of arguments. It might compile, but it would be undefined behaviour. You must define a block that takes three arguments: - The object being inspected - The index of the object. - A pointer to a BOOL that is used to stop early You can see these types here: https://github.com/gnustep/libs-base/blob/6c388830dac190452dd3bce617139a552d78519e/Headers/Foundation/NSArray.h#L177 DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, GS_GENERIC_TYPE(ElementT), NSUInteger, BOOL*); BOOL is the return type of the block. GS_GENERIC_TYPE(ElementT) is an ugly macro that allows us to use generic types with modern compilers and fall back to id for older ones. The type of the first argument to the block is therefore either id (for older compilers or for arrays that don’t use generics) or the generic type of the NSArray (e.g. NSString for NSArray<NSString>). NSInteger and BOOL* are the types of the next two arguments. David _______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
