Use block callback in ZBARSDK block to empty after successful scan

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.