zhangyu9050 / cocoabarcodes

Automatically exported from code.google.com/p/cocoabarcodes
0 stars 0 forks source link

NKDUPCEBarcodes crashes on 11 character string #6

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Pass an 11 character content string to NKDUPCEBarcode initWithContent: 
(NSString *)inContent
       printsCaption: (BOOL)inPrints

What is the expected output? What do you see instead?

It crashes.

What version of the product are you using? On what operating system?

using netshade's fork for iPhone on github

Please provide any additional information below.

The problem is that it tries to convert from UPCA to UPCE using the UPCAToUPCE 
method. Problem is that it is a class method not an instance method so it needs 
to be called on the class not the instance.

The fix is to change this code in NKDUPCEBarcode.m
    if([[self content] length] == 11)
        [self setContent:[self UPCAToUPCE:[NSString stringWithFormat:@"%@%c", [self content], [self checkDigit]]]];

to this:

    if([[self content] length] == 11)
        [self setContent:[NKDUPCEBarcode UPCAToUPCE:[NSString stringWithFormat:@"%@%c", [self content], [self checkDigit]]]];

Original issue reported on code.google.com by dalewk...@gmail.com on 9 Feb 2011 at 6:49