Block variable syntax related question
Block variable syntax related question
- Subject: Block variable syntax related question
- From: David Hoerl <email@hidden>
- Date: Fri, 09 Sep 2011 13:56:35 -0400
I had an issue (rdar://10100914) where the compiler did not properly
determine the return type, forcing me to use a local variable:
typedef BOOL (^tester)(id obj, NSUInteger idx, BOOL *stop);
tester finder = ^(id obj, NSUInteger idx, BOOL *stop) { return ret =
[obj compare:@"foo"] == 0 ? YES : NO; };
error: incompatible block pointer types initializing 'tester' (aka 'BOOL
(^)(id, NSUInteger, BOOL *)')
with an expression of type
'int (^) id, NSUInteger, BOOL *)'
[BTW, this worked: :
tester finder = ^(id obj, NSUInteger idx, BOOL *stop) { BOOL ret = [obj
compare:@"foo"] == 0 ? YES : NO; return ret; };]
I tried various ways to add the return type to the declaration, eg
tester finder = BOOL (^)(id obj, NSUInteger idx, BOOL *stop) { BOOL
ret = [obj compare:@"foo"] == 0 ? YES : NO; return ret; };
but could never get anything to compile. Is there a way to add the
return type above? I am guessing no as I have not found any such
examples, but figured I'd ask just in case...
David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden