Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot initialize parameter and I don't understand why

Tags:

ios

zxing

I get this error:

Cannot initialize a parameter of type 'id<ZXingDelegate>'
with an lvalue of type 'FirstViewController *const __strong'

From this line of code:

ZXingWidgetController *widController =
    [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES
                                                           OneDMode:NO];

How can I solve this?

like image 478
Pillblast Avatar asked Nov 29 '11 09:11

Pillblast


2 Answers

Thanks to Macmade's comment I managed to solve the problem. I should have written it this way:

ZXingWidgetController *widController =
    [[ZXingWidgetController alloc] initWithDelegate:***(id)** self showCancel:YES 
                                                                     OneDMode:NO];

Where (id) is the bridged cast he was talking about.

like image 195
Pillblast Avatar answered Sep 30 '22 05:09

Pillblast


use this line off code for this issue

ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:(id<ZXingDelegate>)self showCancel:YES OneDMode:NO];
like image 31
Muaz Ishfaq Avatar answered Sep 30 '22 05:09

Muaz Ishfaq