Skip to content

Commit 64c3f9d

Browse files
committed
even more selector syntax changes for Swift 2.2
1 parent 4409c55 commit 64c3f9d

File tree

28 files changed

+49
-49
lines changed

28 files changed

+49
-49
lines changed

bk2ch08p438searchableTable4/ch21p718sections/SearchResultsController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SearchResultsController : UIViewController {
2727
v.centerXAnchor.constraintEqualToAnchor(self.view.centerXAnchor)
2828
])
2929
self.child.didMoveToParentViewController(self)
30-
let t = UITapGestureRecognizer(target: self, action: "tap:")
30+
let t = UITapGestureRecognizer(target: self, action: #selector(tap))
3131
t.delegate = self
3232
self.view.addGestureRecognizer(t)
3333
}

bk2ch08p451dynamicTableContent/ch21p718sections/RootViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class RootViewController : UITableViewController {
116116
options:[], metrics:nil, views:["lab":lab])
117117
].flatten().map{$0})
118118
// add tap g.r.
119-
let tap = UITapGestureRecognizer(target: self, action: "tap:") // *
119+
let tap = UITapGestureRecognizer(target: self, action: #selector(tapped)) // *
120120
tap.numberOfTapsRequired = 2 // *
121121
h.addGestureRecognizer(tap) // *
122122
}
@@ -130,7 +130,7 @@ class RootViewController : UITableViewController {
130130
return self.sectionNames
131131
}
132132

133-
func tap (g : UIGestureRecognizer) {
133+
func tapped (g : UIGestureRecognizer) {
134134
let v = g.view as! MyHeaderView
135135
let sec = v.section
136136
let ct = self.sectionData[sec].count

bk2ch08p453tableCellMenus/ch21p718sections/RootViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ class RootViewController : UITableViewController {
107107
}
108108

109109
override func tableView(tableView: UITableView, canPerformAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) -> Bool {
110-
return action == "copy:"
110+
return action == #selector(copy(_:))
111111
}
112112

113113
override func tableView(tableView: UITableView, performAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) {
114-
if action == "copy:" {
114+
if action == #selector(copy(_:)) {
115115
// ... do whatever copying consists of ...
116116
print("copying \(self.sectionData[indexPath.section][indexPath.row])")
117117
}

bk2ch08p454tableCellMenus2/ch21p718sections/RootViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,21 @@ class RootViewController : UITableViewController {
109109
// I'm not sure I like this, since it means this class can't be agnostic about it
110110

111111
override func tableView(tableView: UITableView, shouldShowMenuForRowAtIndexPath indexPath: NSIndexPath) -> Bool {
112-
let mi = UIMenuItem(title: "Abbrev", action: #selector(MyCell.abbrev(_:)))
112+
let mi = UIMenuItem(title: "Abbrev", action: #selector(MyCell.abbrev))
113113
UIMenuController.sharedMenuController().menuItems = [mi]
114114
return true
115115
}
116116

117117
override func tableView(tableView: UITableView, canPerformAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) -> Bool {
118-
return action == #selector(copy(_:)) || action == #selector(MyCell.abbrev(_:))
118+
return action == #selector(copy(_:)) || action == #selector(MyCell.abbrev)
119119
}
120120

121121
override func tableView(tableView: UITableView, performAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) {
122122
if action == #selector(copy(_:)) {
123123
// ... do whatever copying consists of ...
124124
print("copying \(self.sectionData[indexPath.section][indexPath.row])")
125125
}
126-
if action == #selector(MyCell.abbrev(_:)) {
126+
if action == #selector(MyCell.abbrev) {
127127
// ... do whatever abbreviating consists of ...
128128
print("abbreviating \(self.sectionData[indexPath.section][indexPath.row])")
129129
}

bk2ch08p466collectionViewFlowLayout2/ch21p748collectionViewFlowLayout2/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ class ViewController : UICollectionViewController, UICollectionViewDelegateFlowL
241241
// NB As in the table view example, we have to help Swift resolve capital(_:)
242242

243243
override func collectionView(collectionView: UICollectionView, shouldShowMenuForItemAtIndexPath indexPath: NSIndexPath) -> Bool {
244-
let mi = UIMenuItem(title:"Capital", action:#selector(Cell.capital(_:)))
244+
let mi = UIMenuItem(title:"Capital", action:#selector(Cell.capital))
245245
UIMenuController.sharedMenuController().menuItems = [mi]
246246
return true
247247
}
248248

249249
override func collectionView(collectionView: UICollectionView, canPerformAction action: Selector, forItemAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) -> Bool {
250-
return (action == #selector(copy(_:))) || (action == #selector(Cell.capital(_:)))
250+
return (action == #selector(copy(_:))) || (action == #selector(Cell.capital))
251251
}
252252

253253
override func collectionView(collectionView: UICollectionView, performAction action: Selector, forItemAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) {
@@ -256,7 +256,7 @@ class ViewController : UICollectionViewController, UICollectionViewDelegateFlowL
256256
if action == #selector(copy(_:)) {
257257
print ("copying \(state)")
258258
}
259-
else if action == #selector(Cell.capital(_:)) {
259+
else if action == #selector(Cell.capital) {
260260
print ("fetching the capital of \(state)")
261261
}
262262
}

bk2ch08p467collectionViewLayoutFromScratchSwift/ch21p748collectionViewFlowLayout2/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ViewController : UICollectionViewController {
3535
sectionData[sectionData.count-1].append( aState )
3636
}
3737
self.navigationItem.title = "States"
38-
let bb = UIBarButtonItem(title:"Push", style:.Plain, target:self, action:"doPush:")
38+
let bb = UIBarButtonItem(title:"Push", style:.Plain, target:self, action:#selector(doPush))
3939
self.navigationItem.rightBarButtonItem = bb
4040
self.collectionView!.backgroundColor = UIColor.whiteColor()
4141
self.collectionView!.allowsMultipleSelection = true

bk2ch08p467collectionViewLayoutFromScratchSwift/ch21p748collectionViewFlowLayout2/ViewController2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ViewController2 : UICollectionViewController {
1111
override func viewDidLoad() {
1212
super.viewDidLoad()
1313
self.navigationItem.title = "States 2"
14-
let b = UIBarButtonItem(title:"Flush", style:.Plain, target:self, action:"doFlush:")
14+
let b = UIBarButtonItem(title:"Flush", style:.Plain, target:self, action:#selector(doFlush))
1515
self.navigationItem.rightBarButtonItem = b
1616
if let flow = self.collectionViewLayout as? UICollectionViewFlowLayout {
1717
flow.headerReferenceSize = CGSizeMake(50,50)

bk2ch09p476popovers/ch22p751popovers/ViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ class ViewController : UIViewController {
2525
// vc.modalInPopover = true
2626
let nav = UINavigationController(rootViewController: vc)
2727
let b = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self,
28-
action: "cancelPop1:")
28+
action: #selector(cancelPop1))
2929
vc.navigationItem.rightBarButtonItem = b
3030
let b2 = UIBarButtonItem(barButtonSystemItem: .Done, target: self,
31-
action: "savePop1:")
31+
action: #selector(savePop1))
3232
vc.navigationItem.leftBarButtonItem = b2
3333
let bb = UIButton(type:.InfoDark)
34-
bb.addTarget(self, action:"doPresent:", forControlEvents:.TouchUpInside)
34+
bb.addTarget(self, action:#selector(doPresent), forControlEvents:.TouchUpInside)
3535
bb.sizeToFit()
3636
vc.navigationItem.titleView = bb
3737
//hmm, this feels like a bug: merely examining the presentation controller...
@@ -123,7 +123,7 @@ class ViewController : UIViewController {
123123
label.center = CGPointMake(150,150)
124124
label.frame = CGRectIntegral(label.frame)
125125
vc.view.addSubview(label)
126-
let t = UITapGestureRecognizer(target:self, action:"tapped:")
126+
let t = UITapGestureRecognizer(target:self, action:#selector(tapped))
127127
vc.view.addGestureRecognizer(t)
128128

129129
if let pop = vc.popoverPresentationController {
@@ -158,7 +158,7 @@ class ViewController : UIViewController {
158158
b.center = CGPointMake(150,150)
159159
b.frame = b.frame.integral
160160
b.autoresizingMask = .None
161-
b.addTarget(self, action:"done:", forControlEvents:.TouchUpInside)
161+
b.addTarget(self, action:#selector(done), forControlEvents:.TouchUpInside)
162162
vc.view.addSubview(b)
163163
// uncomment next line if you'd like to experiment
164164
// previously, only coverVertical was legal, but this restriction is lifted

bk2ch09p477popoversOnPhone/PopoverOnPhone/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extension ViewController : UIPopoverPresentationControllerDelegate {
6464
if style != .Popover {
6565
let vc = controller.presentedViewController
6666
let nav = UINavigationController(rootViewController: vc)
67-
let b = UIBarButtonItem(barButtonSystemItem: .Done, target: self, action: "dismissHelp:")
67+
let b = UIBarButtonItem(barButtonSystemItem: .Done, target: self, action: #selector(dismissHelp))
6868
vc.navigationItem.rightBarButtonItem = b
6969
return nav
7070
}

bk2ch09p488universalSplitViewControllerStoryboardTemplateAnalysis/UniversalStoryboard/DetailViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ extension DetailViewController {
6262

6363
override func respondsToSelector(aSelector: Selector) -> Bool {
6464
let ok = super.respondsToSelector(aSelector)
65-
if aSelector == "showDetailViewController:sender:" {
65+
if aSelector == #selector(showDetailViewController) {
6666
print("detail responds? \(ok)")
6767
}
6868
return ok
6969
}
7070

7171
override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
7272
let ok = super.canPerformAction(action, withSender:sender)
73-
if action == "showDetailViewController:sender:" {
73+
if action == #selector(showDetailViewController) {
7474
print("detail can perform? \(ok)")
7575
}
7676
return ok

bk2ch09p488universalSplitViewControllerStoryboardTemplateAnalysis/UniversalStoryboard/MasterNavigationViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ class MasterNavigationViewController : UINavigationController {
4242

4343
override func respondsToSelector(aSelector: Selector) -> Bool {
4444
let ok = super.respondsToSelector(aSelector)
45-
if aSelector == "showDetailViewController:sender:" {
45+
if aSelector == #selector(showDetailViewController) {
4646
print("master NAV responds? \(ok)")
4747
}
4848
return ok
4949
}
5050

5151
override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
5252
let ok = super.canPerformAction(action, withSender:sender)
53-
if action == "showDetailViewController:sender:" {
53+
if action == #selector(showDetailViewController) {
5454
print("master NAV can perform? \(ok)")
5555
}
5656
return ok

bk2ch09p488universalSplitViewControllerStoryboardTemplateAnalysis/UniversalStoryboard/MasterViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MasterViewController: UITableViewController {
2626
super.viewDidLoad()
2727

2828
self.navigationItem.leftBarButtonItem = self.editButtonItem()
29-
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "insertNewObject:")
29+
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: #selector(insertNewObject))
3030
self.navigationItem.rightBarButtonItem = addButton
3131
// these next lines do not actually do anything,
3232
// so I've taken them out as they are just confusing
@@ -126,15 +126,15 @@ extension MasterViewController {
126126

127127
override func respondsToSelector(aSelector: Selector) -> Bool {
128128
let ok = super.respondsToSelector(aSelector)
129-
if aSelector == "showDetailViewController:sender:" {
129+
if aSelector == #selector(showDetailViewController) {
130130
print("master responds? \(ok)")
131131
}
132132
return ok
133133
}
134134

135135
override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
136136
var ok = super.canPerformAction(action, withSender:sender)
137-
if action == "showDetailViewController:sender:" {
137+
if action == #selector(showDetailViewController) {
138138
ok = false
139139
print("master can perform? \(ok)")
140140
}

bk2ch09p488universalSplitViewControllerStoryboardTemplateAnalysis/UniversalStoryboard/MySplitViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ class MySplitViewController: UISplitViewController {
3131

3232
override func respondsToSelector(aSelector: Selector) -> Bool {
3333
let ok = super.respondsToSelector(aSelector)
34-
if aSelector == "showDetailViewController:sender:" {
34+
if aSelector == #selector(showDetailViewController) {
3535
print("svc responds? \(ok)")
3636
}
3737
return ok
3838
}
3939

4040
override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
4141
let ok = super.canPerformAction(action, withSender:sender)
42-
if action == "showDetailViewController:sender:" {
42+
if action == #selector(showDetailViewController) {
4343
print("svc can perform? \(ok)")
4444
}
4545
return ok

bk2ch09p489universalSplitViewControllerStoryboard2/UniversalStoryboard/MasterViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MasterViewController: UITableViewController {
2222
super.viewDidLoad()
2323

2424
self.navigationItem.leftBarButtonItem = self.editButtonItem()
25-
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "insertNewObject:")
25+
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: #selector(insertNewObject))
2626
self.navigationItem.rightBarButtonItem = addButton
2727
// these next lines do not actually do anything,
2828
// so I've taken them out as they are just confusing

bk2ch09p490universalSplitViewControllerManual/SplitViewControllerManual/PrimaryViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PrimaryViewController : UIViewController {
3434
seg.centerXAnchor.constraintEqualToAnchor(self.view.centerXAnchor),
3535
seg.bottomAnchor.constraintEqualToAnchor(self.view.bottomAnchor, constant:-50)
3636
])
37-
seg.addTarget(self, action: "change:", forControlEvents: .ValueChanged)
37+
seg.addTarget(self, action: #selector(change), forControlEvents: .ValueChanged)
3838
}
3939

4040
func change(sender:AnyObject) {
@@ -90,7 +90,7 @@ extension UIViewController {
9090
// how to use targetViewControllerForAction to look up the hierarchy
9191
// we don't know who implements showHide or where he is in the hierarchy,
9292
// and we don't care! agnostic messaging up the hierarchy
93-
let target = self.targetViewControllerForAction("showHide:", sender: sender)
93+
let target = self.targetViewControllerForAction(#selector(showHide), sender: sender)
9494
if target != nil {
9595
target!.showHide(self)
9696
}

bk2ch09p490universalSplitViewControllerManual/SplitViewControllerManual/SecondaryViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SecondaryViewController : UIViewController {
1111
let b = UIButton(type:.System)
1212
b.setTitle("Configure", forState: .Normal)
1313
b.backgroundColor = UIColor.yellowColor()
14-
b.addTarget(self, action: "callShowHide:", forControlEvents: .TouchUpInside)
14+
b.addTarget(self, action: #selector(callShowHide), forControlEvents: .TouchUpInside)
1515
self.view.addSubview(b)
1616
b.translatesAutoresizingMaskIntoConstraints = false
1717
NSLayoutConstraint.activateConstraints([

bk2ch09p490universalSplitViewControllerManual/SplitViewControllerManual/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ViewController: UIViewController {
3131
// This is the kind of "loose coupling" that Apple is after here
3232

3333
override func targetViewControllerForAction(action: Selector, sender: AnyObject?) -> UIViewController? {
34-
if action == "showHide:" {
34+
if action == #selector(showHide) {
3535
let svc = self.childViewControllers[0] as! UISplitViewController
3636
let primary = svc.viewControllers[0]
3737
if primary.canPerformAction(action, withSender: sender) {

bk2ch10p495TableWithDynamicType/TableWithDynamicType/MasterViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MasterViewController: UITableViewController {
1616
// Do any additional setup after loading the view, typically from a nib.
1717
self.navigationItem.leftBarButtonItem = self.editButtonItem()
1818

19-
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "insertNewObject:")
19+
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: #selector(insertNewObject))
2020
self.navigationItem.rightBarButtonItem = addButton
2121
}
2222

bk2ch10p495dynamicType/ch23p670font1dynamicType/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ViewController : UIViewController {
1313

1414
override func viewDidLoad() {
1515
super.viewDidLoad()
16-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "doDynamicType:", name: UIContentSizeCategoryDidChangeNotification, object: nil)
16+
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(doDynamicType), name: UIContentSizeCategoryDidChangeNotification, object: nil)
1717

1818
// UIFont.familyNames().map {UIFont.fontNamesForFamilyName($0)}
1919
// .forEach {(n:[String]) in n.forEach {print($0)}}

bk2ch10p498fontDescriptor/ch23p670font1dynamicType/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ViewController : UIViewController {
99
override func viewDidLoad() {
1010
super.viewDidLoad()
1111
self.doDynamicType(nil)
12-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "doDynamicType:", name: UIContentSizeCategoryDidChangeNotification, object: nil)
12+
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(doDynamicType), name: UIContentSizeCategoryDidChangeNotification, object: nil)
1313

1414
let f = UIFont(name: "Avenir", size: 15)!
1515
let desc = f.fontDescriptor()

bk2ch10p520textFieldSliding/ch23p805textFieldSliding/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ViewController: UIViewController, UITextFieldDelegate {
1111
override func viewDidLoad() {
1212
super.viewDidLoad()
1313

14-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardShow:", name: UIKeyboardWillShowNotification, object: nil)
15-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardHide:", name: UIKeyboardWillHideNotification, object: nil)
14+
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(keyboardShow), name: UIKeyboardWillShowNotification, object: nil)
15+
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(keyboardHide), name: UIKeyboardWillHideNotification, object: nil)
1616
}
1717

1818
func textFieldDidBeginEditing(tf: UITextField) {

bk2ch10p522textFieldScrollView/ch23p805textFieldSliding/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class ViewController: UIViewController {
1313
override func viewDidLoad() {
1414
super.viewDidLoad()
1515

16-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardShow:", name: UIKeyboardWillShowNotification, object: nil)
17-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardHide:", name: UIKeyboardWillHideNotification, object: nil)
16+
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(keyboardShow), name: UIKeyboardWillShowNotification, object: nil)
17+
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(keyboardHide), name: UIKeyboardWillHideNotification, object: nil)
1818

1919
let contentView = self.scrollView.subviews[0]
2020
NSLayoutConstraint.activateConstraints([

bk2ch10p524keyboardAccessory/ch21p808keyboardAccessory/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ViewController: UIViewController {
1313
let arr = UINib(nibName:"AccessoryView", bundle:nil).instantiateWithOwner(nil, options:nil)
1414
self.accessoryView = arr[0] as! UIView
1515
let b = self.accessoryView.subviews[0] as! UIButton
16-
b.addTarget(self, action:"doNextButton:", forControlEvents:.TouchUpInside)
16+
b.addTarget(self, action:#selector(doNextButton), forControlEvents:.TouchUpInside)
1717

1818
}
1919

bk2ch10p525ShortcutsBarTest/ShortcutsBarTest/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ViewController: UIViewController {
1414
switch which {
1515
case 1:
1616
let bbi = UIBarButtonItem(
17-
barButtonSystemItem: .Camera, target: self, action: "doCamera:")
17+
barButtonSystemItem: .Camera, target: self, action: #selector(doCamera))
1818
let group = UIBarButtonItemGroup(
1919
barButtonItems: [bbi], representativeItem: nil)
2020
let shortcuts = self.tf.inputAssistantItem
@@ -23,7 +23,7 @@ class ViewController: UIViewController {
2323
case 2:
2424
var bbis = [UIBarButtonItem]()
2525
for _ in 1...5 {
26-
let bbi = UIBarButtonItem(barButtonSystemItem: .Camera, target: self, action: "doCamera:")
26+
let bbi = UIBarButtonItem(barButtonSystemItem: .Camera, target: self, action: #selector(doCamera))
2727
bbis.append(bbi)
2828
}
2929
let rep = UIBarButtonItem(barButtonSystemItem: .Edit, target: nil, action: nil)

bk2ch10p526textFieldDelegate/ch23p810textFieldDelegate/MyTextField.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MyTextField: UITextField {
1818

1919

2020
override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
21-
if action == "expand:", let r = self.selectedTextRange,
21+
if action == #selector(expand), let r = self.selectedTextRange,
2222
let s = self.textInRange(r) {
2323
return s.characters.count == 2 && self.stateForAbbrev(s) != nil
2424
}

0 commit comments

Comments
 (0)