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

swift 2.2 Does not work with latest xcode/swift update - selectors is deprecated #23

Open
kiwo12345 opened this issue Mar 29, 2016 · 6 comments

Comments

@kiwo12345
Copy link

I get a few warnings saying that the selectors need to change form:
self.addTarget(self, action: "touchDown:", forControlEvents: UIControlEvents.TouchDown)
self.addTarget(self, action: "touchUpInside:", forControlEvents: UIControlEvents.TouchUpInside)
self.addTarget(self, action: "touchDragExit:", forControlEvents: UIControlEvents.TouchDragExit)
self.addTarget(self, action: "touchDragEnter:", forControlEvents: UIControlEvents.TouchDragEnter)
self.addTarget(self, action: "touchCancel:", forControlEvents: UIControlEvents.TouchCancel)
to:

self.addTarget(self, action: #selector(DOFavoriteButton.touchDown(:)), forControlEvents: UIControlEvents.TouchDown)
self.addTarget(self, action: #selector(DOFavoriteButton.touchUpInside(
:)), forControlEvents: UIControlEvents.TouchUpInside)
self.addTarget(self, action: #selector(DOFavoriteButton.touchDragExit(:)), forControlEvents: UIControlEvents.TouchDragExit)
self.addTarget(self, action: #selector(DOFavoriteButton.touchDragEnter(
:)), forControlEvents: UIControlEvents.TouchDragEnter)
self.addTarget(self, action: #selector(DOFavoriteButton.touchCancel(_:)), forControlEvents: UIControlEvents.TouchCancel)

But updating the selectors will result in my app crashing giving me the error:
libc++abi.dylib: terminating with uncaught exception of type NSException

[Test.DOFavoriteButton select:]: unrecognized selector sent to instance 0x7fea9ad6f480
2016-03-29 23:07:17.286 Test[16889:2397051] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Test.DOFavoriteButton select:]: unrecognized selector sent to instance 0x7fea9ad6f480'

@kiwo12345 kiwo12345 changed the title Does not work with latest xcode/swift update - selectors is deprecated swift 2.2 Does not work with latest xcode/swift update - selectors is deprecated Mar 29, 2016
@kiwo12345
Copy link
Author

Okey I got it working now..
If anyone is using Swift 2.2 change addTargets() to:

private func addTargets() {
        //===============
        // add target
        //===============
        self.addTarget(self, action: #selector(DOFavoriteButton.touchDown(_:)), forControlEvents: UIControlEvents.TouchDown)
        self.addTarget(self, action: #selector(DOFavoriteButton.touchUpInside(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        self.addTarget(self, action: #selector(DOFavoriteButton.touchDragExit(_:)), forControlEvents: UIControlEvents.TouchDragExit)
        self.addTarget(self, action: #selector(DOFavoriteButton.touchDragEnter(_:)), forControlEvents: UIControlEvents.TouchDragEnter)
        self.addTarget(self, action: #selector(DOFavoriteButton.touchCancel(_:)), forControlEvents: UIControlEvents.TouchCancel)
    }

then change select() to

public func select() {
        select(animate: true)
    }

@grantkemp
Copy link

There is a pull request to fix this code.. will it be merged?

@sinanku
Copy link

sinanku commented May 1, 2016

Waiting on this merge to implement

@jwardle
Copy link

jwardle commented Jul 6, 2016

+1

@angadn
Copy link

angadn commented Jul 7, 2016

Doing a Carthage build doesn't work either - most likely because of this same issue. Waiting to be able to use this framework!

@galharth
Copy link

@kiwo12345 I can't add animate:true to the select, and getting "[DOFavoriteButton.DOFavoriteButton select:]: unrecognized selector sent to instance "

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

6 participants