0

I have a class which I want to two optional blocks

so in the class.h:

@property (nonatomic, copy) void (^onConnectBlock)(void);

and in a method inside the class:

I have:

_onConnectBlock();

Unfortunately if this is not set:

[class setOnConnectBlock:^{
    [class send:auth];
}];

the app crashes with EXC_BAD_ACCESS.

I have tried to add an exception block but still returns EXC_BAD_ACCESS?

@try {
    _onCloseBlock();
}
@catch (NSException *exception) {

}
maxisme
  • 3,974
  • 9
  • 47
  • 97

1 Answers1

2

You can try this:

if (self.onCloseBlock){
   _onCloseBlock();
}
Aris
  • 1,529
  • 9
  • 17