1

Hi there I'm experiencing a little problem with my project. I made a QR e reader that will scan a bar code and then will search the result on my website but after scanning 6x my app just crash, I hope someone can help me with that.

I'm new with Objective-C and iPhone SDK but I really need this project, thanks.

AppDelegate.h

#import <UIKit/UIKit.h>

@class ViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;

@end

ViewController.h

#import <UIKit/UIKit.h>
#import "ZBarSDK.h"

@interface ViewController : UIViewController<ZBarReaderDelegate> {
    IBOutlet UIWebView *myWeb;
    IBOutlet UITextView *resultTextView;
}

- (IBAction)startScanning:(id)sender;

@end

ViewController.m

#import "ViewController.h"

@interface ViewController ()
@end

@implementation ViewController

#pragma mark - ViewController's LifeCycle methods

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - Button click method

- (IBAction)startScanning:(id)sender {

    ZBarReaderViewController *codeReader = [ZBarReaderViewController new];
    codeReader.readerDelegate=self;
    codeReader.supportedOrientationsMask = ZBarOrientationMaskAll;

    ZBarImageScanner *scanner = codeReader.scanner;
    [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];

    [self presentViewController:codeReader animated:YES completion:nil];
}

#pragma mark - ZBar's Delegate method

- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    //  get the decode results
    id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];

    ZBarSymbol *symbol = nil;
    for(symbol in results)
        // just grab the first barcode
        break;

    NSString *myString = [NSString stringWithFormat:@"http://www.northland-cc.com/%@", symbol.data];
    NSURL *url = [NSURL URLWithString:myString];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [myWeb loadRequest:requestObj];

    // dismiss the controller
    [reader dismissViewControllerAnimated:YES completion:nil];
}

@end
gilpenner
  • 11
  • 1
  • what sort of error message did you get - can you post some details? – acutesoftware Oct 05 '13 at 01:40
  • I don't get any error, the app just stop at all and nothing works so I have to close and relaunch the app. – gilpenner Oct 06 '13 at 02:40
  • You might find something testworthy here: http://stackoverflow.com/questions/19019607/zbar-sdk-and-ios7-xcode-5-app-is-reaching-100-cpu-use-and-memory-more-than-10 I still haven't manage to fix it though. – nj. Oct 21 '13 at 09:23

0 Answers0