Search code examples
ioszxing

Cannot initialize parameter and I don't understand why


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?


Solution

  • 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.