Today, using the ZBARSDK implementation of the QR code scanning function, using the block callback to pass the scan successfully obtained value but after the successful scan code block becomes empty ... The Heart rubber cork stoppling
The code follows the main page to jump to the sweep code interface
// jump to the sweep code interface
Readcodeviewcontroller * READVC = [[readcodeviewcontroller alloc]init];
READVC. Scancoderesult = ^ (nsstring *result)
{
[self addpcdmerch: result];
};
[self presentviewcontroller: READVC animated:YES Completion:nil];
After the code is successfully scanned, the following codes
-( void ) Readerview: ( Zbarreaderview *) Readerview Didreadsymbols: ( zbarsymbolset *) symbols FromImage: ( UIImage *) image
{
[timer invalidate];
[self. Zbarreadview stop];
_line. Frame = cgrectmake( 2);
Const zbar_symbol_t *symbol = zbar_symbol_set_first_symbol (symbols. zbarsymbolset );
nsstring *symbolstr = [ nsstring stringwithutf8string : zbar_symbol_get_data ( Symbol)];
if(self. Scancoderesult)
{
self. Scancoderesult(SYMBOLSTR);
}
[self dismissviewcontrolleranimated:YES completion:nil];
}
At the end of the day, we found out that the problem was in declaring the block
@property (nonatomic, assign) scancoderesultblock scancoderesult;
Use the Assign, change it to strong and then OK.
So let's just say assign strong/weak copy usage.
Assign basic data types
Strong/weak various controls
Copy is used only for assigning values such as NSString
Finally, the copy is used when the block declaration
Use block callback in ZBARSDK block to empty after successful scan