Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on force unwrap of corners #105

Open
cmtrounce opened this issue Oct 27, 2017 · 4 comments
Open

Crash on force unwrap of corners #105

cmtrounce opened this issue Oct 27, 2017 · 4 comments

Comments

@cmtrounce
Copy link

In 'draw' function of RSCornersLayer.swift,

let dict = corners[idx] as! NSDictionary force cast causing a crash.

When scanning a barcode, this causes a hard crash.

@akuehlewind
Copy link
Contributor

akuehlewind commented Oct 27, 2017

Got the same error RSCornersLayer.swift -> 41

To fix it replace:

let dict = corners[idx] as! NSDictionary
                
                let x = CGFloat((dict.object(forKey: "X") as! NSNumber).floatValue)
                let y = CGFloat((dict.object(forKey: "Y") as! NSNumber).floatValue)
                if i == 0 {
                    ctx.move(to: CGPoint(x: x, y: y))
                } else {
                    ctx.addLine(to: CGPoint(x: x, y: y))
                }

with:

let point = corners[idx] as! CGPoint                
                if i == 0 {
                    ctx.move(to: point)
                } else {
                    ctx.addLine(to: point)
                }

@lotfyahmed
Copy link

Please create new branch (or fork) to fix it with the above solution.

akuehlewind added a commit to akuehlewind/RSBarcodes_Swift that referenced this issue Oct 31, 2017
@lotfyahmed
Copy link

lotfyahmed commented Nov 1, 2017

@akuehlewind Please create pull request to merge it on the master

And how to install this solution from Cocoa pod?

The current profile has:

pod 'RSBarcodes_Swift', :git => 'git@github.com:yeahdongcn/RSBarcodes_Swift.git', :branch => 'master'

Thanks

@lotfyahmed
Copy link

@yeahdongcn Please accept the pull request to fix this crash if it is a correct solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants