I want to call enumerateObjectsUsingBlock print each object in a array when debugging.
But the lldb seems can’t support block ? Is there anyway to make this working ?
(lldb) expr -- [self.choiceQuestion.allNewRecommenedItems enumerateObjectsUsingBlock:void ^(id obj,NSUInteger index,BOOL* stop){NSLog(@"%@",obj);}]
error: <user expression 9>:1:76: expected '(' for function-style cast or type construction
[self.choiceQuestion.allNewRecommenedItems enumerateObjectsUsingBlock:void ^(id obj,NSUInteger index,BOOL* stop){NSLog(@"%@",obj);}]
2
Answers
Thanks JimIngham's answer. A specific answer to print array in lldb will like this:
If I put your example in a source file – to eliminate possible problems with the expression parser – I get the same syntax error you were showing. So apparently this isn’t legal block syntax. But then if I try (just removing the
void
):that successfully compiles. Unsurprisingly, that expression also works in the expression evaluator.
I suspect that since the compiler infers the type of the block from the return value of its body, the return type specification is not allowed, but you’d have to find somebody more familiar with the details of block syntax to say for sure.