Re: Block error
Re: Block error
- Subject: Re: Block error
- From: Jens Alfke <email@hidden>
- Date: Fri, 15 Jul 2011 16:21:07 -0700
On Jul 15, 2011, at 2:42 PM, Rick Mann wrote:
> void
> bar()
> {
> (id) ^(id inParam1)
> {
> if ([inParam1 isEqual: @"baz"])
> {
> Foo* foo = [[Foo alloc] init];
> return foo;
> }
>
> return nil; // Error here
> };
> }
Is this just a test to narrow down the error? Because this code doesn’t actually do anything — it just declares a block literal, casts it to type ‘id’, and ignores the result.
I’m not sure how you explicitly specify the return type of a block, since usually it’s inferred for you by the compiler. You could try assigning the block to a variable of the type you want:
id myblock = ^(id inParam1) { … };
The compiler will then infer that the return type of the block is ‘id’.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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
References: | |
| >Block error (From: Rick Mann <email@hidden>) |