0

I have this declared on the interface

void (^ soc)(NSString *type, BOOL configured);

and

@property (nonatomic, assign) BOOL serviceOK;

Then inside a method on .m I have this:

soc = ^(NSString *type, BOOL configured){
    // ...
};

// other blocks defined here

And then this:

NSMutableArray *arrayBlocks = [[NSMutableArray alloc] initWithObjects:
                               [block1 copy],
                               [soc(typeOne, self.serviceOK) copy],
                               [block3 copy],
                               [block4 copy],
                               nil];

I have an error on the soc line with the message bad receiver type void (what ???)

If I simply run this:

soc(typeOne, self.serviceOK);

it works fine, but if I include it in the array it complains. Any help appreciated.

0

2 Answers 2

2

If you want to add a copy of the block then add:

[soc copy],

to the array. What you are trying to do is add a copy of the result of calling the block.

Sign up to request clarification or add additional context in comments.

Comments

1
soc(typeOne, self.serviceOK)

executes the block. and as it is returning nothing, there is nothing to send the copy message to and put into the array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.