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.

4

2 に答える 2

2

ブロックのコピーを追加する場合は、次を追加します。

[soc copy],

アレイに。あなたがやろうとしているのは、ブロックを呼び出した結果のコピーを追加することです。

于 2012-11-26T03:25:05.937 に答える
1
soc(typeOne, self.serviceOK)

ブロックを実行します。また、何も返さないため、コピーメッセージを送信して配列に入れるものはありません。

于 2012-11-26T03:24:03.113 に答える