yeahdongcn / RSBarcodes_Swift

1D and 2D barcodes reader and generators for iOS 8 with delightful controls. Now Swift.
MIT License
710 stars 185 forks source link

RSEANGenerator cannot be initialised #51

Closed chetanfaris closed 8 years ago

chetanfaris commented 8 years ago

The isValid function is not accessible because the class cannot be initialised. Is there any reason why the init method is not public?

Thanks Chetan

yeahdongcn commented 8 years ago

You can use the following code to generate EAN family barcode

let gen = RSUnifiedCodeGenerator.shared
let image: UIImage? = gen.generateCode(contents, machineReadableCodeObjectType: AVMetadataObjectTypeEAN8Code) // AVMetadataObjectTypeEAN13Code, RSBarcodesTypeISBN13Code, RSBarcodesTypeISSN13Code
yeahdongcn commented 8 years ago

isValid is designed to make sure the user input is correct before generating the barcode

gps commented 8 years ago

isValid is designed to make sure the user input is correct before generating the barcode

@yeahdongcn: Makes sense.

However, it would be useful to be able to use isValid without having to generate a UIImage. For instance, it'd be handy to be able to validate a bar code String before sending it up to a server.

If this is something you'd rather not support though, I understand 😀. If it is, and you'd like a PR, I can try to take a crack at it - please let me know.

yeahdongcn commented 8 years ago

I can add one method in RSUnifiedCodeGenerator, one PR is welcomed.

yeahdongcn commented 8 years ago

Could you take a look at the new commit, I just add a new class for this.

gps commented 8 years ago

Works great, thank you for the fast response! Filed #52 to add this functionality to README.

gps commented 8 years ago

Would be even more phenomenal if you could do a release :smile:.

yeahdongcn commented 8 years ago

No problem, give me two hours to finish a helper method.

gps commented 8 years ago

Thanks @yeahdongcn!