• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Block variable syntax related question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Block variable syntax related question
      • From: Jean-Denis MUYS <email@hidden>
    • Re: Block variable syntax related question
      • From: Bavarious <email@hidden>
  • Prev by Date: Re: Source code generation in Xcode 4
  • Next by Date: Re: Source code generation in Xcode 4
  • Previous by thread: Re: Source code generation in Xcode 4
  • Next by thread: Re: Block variable syntax related question
  • Index(es):
    • Date
    • Thread