From 30ce9526435585356cf39614009d57d2b36e048b Mon Sep 17 00:00:00 2001 From: Chucky Date: Thu, 11 Aug 2016 09:56:03 -0700 Subject: [PATCH] updating selectors syntax --- .../DOFavoriteButton-DEMO/ViewController.swift | 10 +++++----- DOFavoriteButton/DOFavoriteButton.swift | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift index 99be5ed..65492c8 100644 --- a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift +++ b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift @@ -22,7 +22,7 @@ class ViewController: UIViewController { // star button let starButton = DOFavoriteButton(frame: CGRectMake(x, y, 44, 44), image: UIImage(named: "star")) - starButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + starButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside) self.view.addSubview(starButton) x += width @@ -31,7 +31,7 @@ class ViewController: UIViewController { heartButton.imageColorOn = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0) heartButton.circleColor = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0) heartButton.lineColor = UIColor(red: 226/255, green: 96/255, blue: 96/255, alpha: 1.0) - heartButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + heartButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside) self.view.addSubview(heartButton) x += width @@ -40,7 +40,7 @@ class ViewController: UIViewController { likeButton.imageColorOn = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0) likeButton.circleColor = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0) likeButton.lineColor = UIColor(red: 41/255, green: 128/255, blue: 185/255, alpha: 1.0) - likeButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + likeButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside) self.view.addSubview(likeButton) x += width @@ -49,10 +49,10 @@ class ViewController: UIViewController { smileButton.imageColorOn = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0) smileButton.circleColor = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0) smileButton.lineColor = UIColor(red: 45/255, green: 195/255, blue: 106/255, alpha: 1.0) - smileButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + smileButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside) self.view.addSubview(smileButton) - self.heartButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + self.heartButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside) } override func didReceiveMemoryWarning() { diff --git a/DOFavoriteButton/DOFavoriteButton.swift b/DOFavoriteButton/DOFavoriteButton.swift index 4b7e9b8..48158c5 100644 --- a/DOFavoriteButton/DOFavoriteButton.swift +++ b/DOFavoriteButton/DOFavoriteButton.swift @@ -338,11 +338,11 @@ public class DOFavoriteButton: UIButton { //=============== // add target //=============== - 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) + 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) } func touchDown(sender: DOFavoriteButton) {