bardecode.com

  • Increase font size
  • Default font size
  • Decrease font size
Home Knowledge Base Using the iPhone SDK

Using the iPhone SDK

This is a short guide to explain the steps involved in adding the Softek Barcode Reader SDK to your XCode project. Note that the SDk currently only works with the iPhone 3GS. Please note that the evaluation download includes a project called iBardecode which demonstrates all the steps set out below...

1. Add the Bardecode.m and Bardecode.h source files to your project. These source files form the Bardecode class and handle all the calls to the underlying barcode reader library. You may need to modify the #include line in Bardecode.h to make sure it points to the barcode.h header file.

2. In your pch file add the line:

#import "Bardecode.h"

3. In the Target Info Window (double click on the name of your project under Targets)...

3a. Click on Build and scroll down to Search Paths. Double click in the field next to Library Search Paths and add a line similar to:

$(SRCROOT)/path/to/the/barcode/sdk/Release$(EFFECTIVE_PLATFORM_NAME)

replacing path/to/the/barcode/sdk with the approriate value to find the Softek Barcode SDK on your system.

3b. Click on General and find one of the libbardecode.a files in the SDK. Note that it doesn't matter which one you find so long as you have a library search path that finds the correct libbardecode.a file according to the type of build you may perform.

4. To call the toolkit to read a barcode please add the following code some where in your UIViewController class:

// Probably best in the class header file...
Bardecode *barcode

// Insert into viewDidLoad
barcode = [Bardecode alloc] ;
[barcode init] ;
barcode.Delegate = self ;

// And in the function where you want to read kick off the barcode scan...
barcode.ReadEAN13 = true;
barcode.ReadUPCA = true ;
barcode.ReadUPCE = true ;
barcode.ReadEAN8 = true ;
[barcode ScanBarcodeFromViewFinder] ;

...and also add the notification function into the class...

- (void) BardecodeDidFinish:(NSNotification*)notification {
        if ([[notification name] isEqualToString:@"BarcodeDidRead"])
        {
                // Success - Do something with [barcode BarcodeValue] and [barcode BarcodeType]
        }
        else if ([[notification name] isEqualToString:@"BarcodeDidNotRead"])
        {
                // No barcode found
        }
        else if ([[notification name] isEqualToString:@"UserDidCancel"])
        {
                // User hit cancel 
        }
}