I am working on a project with the Linea Pro Hardware Barcode scanner. For getting started I used the following answer How do I use the Linea-Pro SDK for IOS?
My App consists of a Navigation Controller (table with two entries) and two connected view controllers (each of them uses the scanner).
I am connecting the device in the viewDidLoad of the navigation controller like this:
dtdev=[DTDevices sharedDevice];
[dtdev connect];
In the two view controllers I am registering the device in the viewDidLoad method like this:
dtdev=[DTDevices sharedDevice];
[dtdev addDelegate:self];
[super viewDidLoad];
Unfortunately when I click the device scanning button both delegate methods of the two view controllers are invoked since both where registered for it.
To prevent this behavior I wanted to set the viewController as delegate as soon as the view is visible so I put the [dtdev addDelegate:self]; into the viewWillAppear method and put a [dtdev removeDelegate:self]; in the viewWillDisappear method. After that the bar code scanner will not work anymore after invoking removeDelegate, even if it is added via addDelegate again.
I don't see another way of just adding both view controllers as delegate and then puttin code like this in the delegate methods: "Am I visible"? --> continue : else break; (But this is stupid, right?)
Is it a bug or am I not thinking straight?