Reputation: 5823
@interface MyClass
@property (nonatomic, copy) SomeBlock someBlock;
@end
- (void)myMethodWithBlock:(SomeBlock)theBlock
{
self.someBlock = theBlock;
[someHelper doSomethingWithCompletionBlock:^(){
self.someBlock(arg1);
}
}
Where self.someBlock(arg1)
gives me EXEC_BAD_ACCESS
, I did define someBlock
to be copied.
What can be the problem?
Upvotes: 1
Views: 459
Reputation:
So it looks like the block is sometimes nil
. When a block is invoked, it's dereferenced, but dereferencing nil
and NULL
crashes the app. Check for if (self.someBlock != nil)
and it should not crash anymore.
Upvotes: 1