2

I have a block called myBlock.

I put a breakpoint after the creation of myBlock. In the console, I type

  p myBlock(@"5")

All I get is the error

 error: called object type '__block_literal_generic *' is not a function or function pointer
 error: 1 errors parsing expression

So, it it possible to evaluate in block in the debugger console?

PS: More code

NSArray * array = @[@"a", @"b"] ;

BOOL (^myBlock)(NSString *) = ^BOOL(NSString * string)
    {
        return [string isEqualToString:@"hello"] ;
    } ;

// The breakpoint is here

for (NSString * str in array)
{
    myBlock(str) ;
}

1 Answer 1

2

It seems that you have to explicitely cast the variable to the block type:

(lldb) p ( (BOOL(^)(NSString *)) myBlock )(@"hello")
(BOOL) $3 = YES
(lldb) p ( (BOOL(^)(NSString *)) myBlock )(@"world")
(BOOL) $4 = NO
Sign up to request clarification or add additional context in comments.

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.