Skip to content

Commit dd8b1c7

Browse files
committed
Manually resolve errors and warnings
1 parent ecaccde commit dd8b1c7

9 files changed

Lines changed: 36 additions & 35 deletions

File tree

Example/Example/CustomizedTokenField.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,30 @@ extension ICTokenField {
5252

5353
layer.cornerRadius = 5
5454
layer.shouldRasterize = true
55-
layer.rasterizationScale = UIScreen.main().scale
55+
layer.rasterizationScale = UIScreen.main.scale
5656
backgroundColor = UIColor(red:0.8, green:0.32, blue:0.24, alpha:1)
5757

58-
textField.textColor = UIColor.white()
59-
textField.tintColor = UIColor.white()
58+
textField.textColor = UIColor.white
59+
textField.tintColor = UIColor.white
6060
textField.font = UIFont.boldSystemFont(ofSize: 14)
6161

62-
attributedPlaceholder = AttributedString(
62+
attributedPlaceholder = NSAttributedString(
6363
string: String(self.dynamicType),
6464
attributes: [
65-
NSForegroundColorAttributeName: UIColor.white().withAlphaComponent(0.5),
65+
NSForegroundColorAttributeName: UIColor.white.withAlphaComponent(0.5),
6666
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 14)
6767
]
6868
)
6969

7070
normalTokenAttributes = [
71-
NSForegroundColorAttributeName: UIColor.white(),
72-
NSBackgroundColorAttributeName: UIColor.white().withAlphaComponent(0.25),
71+
NSForegroundColorAttributeName: UIColor.white,
72+
NSBackgroundColorAttributeName: UIColor.white.withAlphaComponent(0.25),
7373
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 14)
7474
]
7575

7676
highlightedTokenAttributes = [
7777
NSForegroundColorAttributeName: UIColor(red:0.8, green:0.32, blue:0.24, alpha:1),
78-
NSBackgroundColorAttributeName: UIColor.white(),
78+
NSBackgroundColorAttributeName: UIColor.white,
7979
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 14)
8080
]
8181
}

Example/Example/CustomizedTokenViewController.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
6060

6161
override func viewWillAppear(_ animated: Bool) {
6262
super.viewWillAppear(animated)
63-
tokenField.becomeFirstResponder()
63+
_ = tokenField.becomeFirstResponder()
6464
}
6565

6666
override func viewWillDisappear(_ animated: Bool) {
6767
super.viewWillAppear(animated)
68-
tokenField.resignFirstResponder()
68+
_ = tokenField.resignFirstResponder()
6969
textView.endEditing(true)
7070
}
7171

@@ -102,7 +102,8 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
102102
// MARK: - Private Methods
103103

104104
private func updateTexts() {
105-
textView.text = "[\n " + tokenField.texts.map { "\"" + $0 + "\"" } .joined(separator: ",\n ") + "\n]"
105+
let tokens = tokenField.texts.map { "\"" + $0 + "\"" } .joined(separator: ",\n ")
106+
textView.text = "[\n " + tokens + "\n]"
106107
}
107108

108109
}

Example/Example/ExampleViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ExampleViewController: UITableViewController {
5656
super.loadView()
5757
tableView.register(ExampleCell.self, forCellReuseIdentifier: NSStringFromClass(ExampleCell.self))
5858
tableView.tableFooterView = flipButton
59-
tableView.tableFooterView?.isUserInteractionEnabled
59+
tableView.tableFooterView?.isUserInteractionEnabled = true
6060
}
6161

6262
// MARK: - UITableViewDataSource
@@ -86,7 +86,7 @@ class ExampleViewController: UITableViewController {
8686
let cell = tableView.dequeueReusableCell(withIdentifier: NSStringFromClass(ExampleCell.self), for: indexPath)
8787
switch types[(indexPath as NSIndexPath).section] {
8888
case let type as ICKeyboardDismissTextField.Type:
89-
let textField = type.`init`(boundsSize:requestHandler:)()
89+
let textField = type.init()
9090
textField.leftViewMode = .always
9191
textField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: 15))
9292
textField.placeholder = String(type)
@@ -98,7 +98,7 @@ class ExampleViewController: UITableViewController {
9898

9999
case let type as ICTokenField.Type:
100100
let container = UIView(frame: cell.bounds)
101-
let tokenField = type.`init`(boundsSize:requestHandler:)()
101+
let tokenField = type.init()
102102
tokenField.placeholder = String(type)
103103
tokenField.frame = container.bounds.insetBy(dx: 5, dy: 0)
104104
tokenField.autoresizingMask = [.flexibleWidth, .flexibleHeight]

Example/Example/StoryboardViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ class StoryboardViewController: UITableViewController {
3232
@IBOutlet weak var tokenField: ICTokenField! {
3333
didSet {
3434
tokenField.normalTokenAttributes = [
35-
NSForegroundColorAttributeName: UIColor.white(),
36-
NSBackgroundColorAttributeName: UIColor.white().withAlphaComponent(0.25),
35+
NSForegroundColorAttributeName: UIColor.white,
36+
NSBackgroundColorAttributeName: UIColor.white.withAlphaComponent(0.25),
3737
]
3838

3939
tokenField.highlightedTokenAttributes = [
40-
NSForegroundColorAttributeName: UIColor.darkGray(),
41-
NSBackgroundColorAttributeName: UIColor.white(),
40+
NSForegroundColorAttributeName: UIColor.darkGray,
41+
NSBackgroundColorAttributeName: UIColor.white,
4242
]
4343
}
4444
}

ICInputAccessory.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
ONLY_ACTIVE_ARCH = YES;
225225
SDKROOT = iphoneos;
226226
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
227-
SWIFT_VERSION = 2.3;
227+
SWIFT_VERSION = 3.0;
228228
TARGETED_DEVICE_FAMILY = "1,2";
229229
VERSIONING_SYSTEM = "apple-generic";
230230
VERSION_INFO_PREFIX = "";
@@ -267,7 +267,7 @@
267267
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
268268
MTL_ENABLE_DEBUG_INFO = NO;
269269
SDKROOT = iphoneos;
270-
SWIFT_VERSION = 2.3;
270+
SWIFT_VERSION = 3.0;
271271
TARGETED_DEVICE_FAMILY = "1,2";
272272
VALIDATE_PRODUCT = YES;
273273
VERSIONING_SYSTEM = "apple-generic";

Source/KeyboardDismissTextField/ICKeyboardDismissAccessoryView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class ICKeyboardDismissAccessoryView: UIView {
8787
// MARK: - NSKeyValueCoding
8888

8989
public override func setValue(_ value: AnyObject?, forUndefinedKey key: String) {
90-
if let color = value as? UIColor where key == "buttonColor" {
90+
if let color = value as? UIColor, key == "buttonColor" {
9191
buttonColor = color
9292
}
9393
}

Source/TokenField/ICInsetLabel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ICInsetLabel: UILabel {
3333
case constant(CGFloat)
3434
}
3535

36-
var contentEdgeInsets = UIEdgeInsetsZero
36+
var contentEdgeInsets = UIEdgeInsets.zero
3737
var cornerRadius = CornerRadius.constant(0)
3838

3939
convenience init(contentEdgeInsets: UIEdgeInsets, cornerRadius: CornerRadius = .constant(0)) {
@@ -56,7 +56,7 @@ class ICInsetLabel: UILabel {
5656

5757
// MARK: - UIView
5858

59-
override func intrinsicContentSize() -> CGSize {
59+
override var intrinsicContentSize: CGSize {
6060
let size = super.intrinsicContentSize
6161
return CGSize(
6262
width: contentEdgeInsets.left + size.width + contentEdgeInsets.right,

Source/TokenField/ICToken.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class ICToken: UIView {
111111
}
112112
// Avoid overlapped translucent background colors
113113
attributes[NSBackgroundColorAttributeName] = nil
114-
textLabel.attributedText = AttributedString(string: text, attributes: attributes)
114+
textLabel.attributedText = NSAttributedString(string: text, attributes: attributes)
115115

116116
delimiterLabel.textColor = normalTextAttributes[NSForegroundColorAttributeName] as? UIColor
117117
delimiterLabel.font = normalTextAttributes[NSFontAttributeName] as? UIFont

Source/TokenField/ICTokenField.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
8484
}
8585
set {
8686
if let text = newValue {
87-
attributedPlaceholder = AttributedString(
87+
attributedPlaceholder = NSAttributedString(
8888
string: text,
8989
attributes: [NSForegroundColorAttributeName: UIColor(red: 0.78, green: 0.78, blue: 0.80, alpha: 0.9)]
9090
)
@@ -97,7 +97,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
9797
// MARK: - UI Customization
9898

9999
/// The placeholder with customized attributes.
100-
public var attributedPlaceholder: AttributedString? {
100+
public var attributedPlaceholder: NSAttributedString? {
101101
didSet {
102102
guard let attributedText = attributedPlaceholder else {
103103
placeholderLabel.text = nil
@@ -223,7 +223,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
223223

224224
// MARK: - UIResponder
225225

226-
public override func isFirstResponder() -> Bool {
226+
public override var isFirstResponder: Bool {
227227
return inputTextField.isFirstResponder || super.isFirstResponder
228228
}
229229

@@ -279,12 +279,12 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
279279
}
280280

281281
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
282-
removeHighlightedToken() // as user starts typing when a token is focused
282+
_ = removeHighlightedToken() // as user starts typing when a token is focused
283283
inputTextField.showsCursor = true
284284

285-
guard let
286-
input = textField.text,
287-
text: NSString = (input as NSString).replacingCharacters(in: range, with: string)
285+
guard
286+
let input = textField.text,
287+
let text: NSString = (input as NSString).replacingCharacters(in: range, with: string)
288288
else {
289289
return true
290290
}
@@ -323,11 +323,11 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
323323
}
324324

325325
if !textField.showsCursor {
326-
removeHighlightedToken()
326+
_ = removeHighlightedToken()
327327
return true
328328
}
329329

330-
if let text = textField.text where text.isEmpty {
330+
if let text = textField.text, text.isEmpty {
331331
textField.showsCursor = false
332332
tokens.last?.highlighted = true
333333
}
@@ -342,7 +342,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
342342
}
343343

344344
@objc private func handleTapGesture(_ sender: UITapGestureRecognizer) {
345-
if !isFirstResponder() {
345+
if !isFirstResponder {
346346
inputTextField.becomeFirstResponder()
347347
}
348348

@@ -434,7 +434,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
434434

435435
/// Creates a token with the current input text.
436436
public func completeCurrentInputText() {
437-
guard let text = inputTextField.text where !text.isEmpty else {
437+
guard let text = inputTextField.text, !text.isEmpty else {
438438
return
439439
}
440440
inputTextField.text = nil

0 commit comments

Comments
 (0)