Skip to content

Commit b54719c

Browse files
Kristiyan DobrevBasThomas
Kristiyan Dobrev
authored andcommitted
Swift 4.2 and XCode 10 migration (#89)
* swift 4.2 and xcode 10 migration * bumped xcode version * bumped swift version to 4.2 * fixed tests and removed auto-generated swift migration funcs * removed unused function * omitted prefixes
1 parent 89b13d6 commit b54719c

12 files changed

+49
-66
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: swift
2-
osx_image: xcode9.3
2+
osx_image: xcode10.1
33
script:
4-
- xcodebuild clean test -project MessageViewController.xcodeproj -scheme MessageViewController -destination "platform=iOS Simulator,name=iPhone X,OS=11.3" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet
4+
- xcodebuild clean test -project MessageViewController.xcodeproj -scheme MessageViewController -destination "platform=iOS Simulator,name=iPhone X,OS=11.3" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet

MessageViewController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Pod::Spec.new do |spec|
88
spec.source = { :git => 'https://github.com/GitHawkApp/MessageViewController.git', :tag => spec.version.to_s }
99
spec.source_files = 'MessageViewController/*.swift'
1010
spec.platform = :ios, '9.0'
11-
spec.swift_version = '4.0'
11+
spec.swift_version = '4.2'
1212
end

MessageViewController.xcodeproj/project.pbxproj

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
29792B141FFAE7FC007A0C57 /* MessageTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29792B121FFAE7FC007A0C57 /* MessageTextView.swift */; };
1919
29792B151FFAE7FC007A0C57 /* MessageAutocompleteController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29792B131FFAE7FC007A0C57 /* MessageAutocompleteController.swift */; };
2020
29C8A1FB2187223300AEA4E0 /* MessageTextViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C8A1FA2187223300AEA4E0 /* MessageTextViewTests.swift */; };
21-
29C8A1FD2187D39200AEA4E0 /* DictionaryString+NSAttributedStringKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C8A1FC2187D39200AEA4E0 /* DictionaryString+NSAttributedStringKey.swift */; };
2221
29C8F9A9208BDAC60075931C /* ExpandedHitTestButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29C8F9A8208BDAC60075931C /* ExpandedHitTestButton.swift */; };
2322
29CC293D1FF4266D006B6DE7 /* MessageViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2904820B1FED90070053978C /* MessageViewController.framework */; };
2423
29CC29441FF4267F006B6DE7 /* String+WordAtRangeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29CC29431FF4267F006B6DE7 /* String+WordAtRangeTests.swift */; };
@@ -53,7 +52,6 @@
5352
29792B121FFAE7FC007A0C57 /* MessageTextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageTextView.swift; sourceTree = "<group>"; };
5453
29792B131FFAE7FC007A0C57 /* MessageAutocompleteController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageAutocompleteController.swift; sourceTree = "<group>"; };
5554
29C8A1FA2187223300AEA4E0 /* MessageTextViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTextViewTests.swift; sourceTree = "<group>"; };
56-
29C8A1FC2187D39200AEA4E0 /* DictionaryString+NSAttributedStringKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DictionaryString+NSAttributedStringKey.swift"; sourceTree = "<group>"; };
5755
29C8F9A8208BDAC60075931C /* ExpandedHitTestButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExpandedHitTestButton.swift; sourceTree = "<group>"; };
5856
29CC29381FF4266D006B6DE7 /* MessageViewControllerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MessageViewControllerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5957
29CC293C1FF4266D006B6DE7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -104,7 +102,6 @@
104102
2904820D1FED90070053978C /* MessageViewController */ = {
105103
isa = PBXGroup;
106104
children = (
107-
29C8A1FC2187D39200AEA4E0 /* DictionaryString+NSAttributedStringKey.swift */,
108105
29C8F9A8208BDAC60075931C /* ExpandedHitTestButton.swift */,
109106
2904820F1FED90070053978C /* Info.plist */,
110107
29792B131FFAE7FC007A0C57 /* MessageAutocompleteController.swift */,
@@ -192,16 +189,17 @@
192189
isa = PBXProject;
193190
attributes = {
194191
LastSwiftUpdateCheck = 0920;
195-
LastUpgradeCheck = 0920;
192+
LastUpgradeCheck = 1010;
196193
ORGANIZATIONNAME = "Ryan Nystrom";
197194
TargetAttributes = {
198195
2904820A1FED90070053978C = {
199196
CreatedOnToolsVersion = 9.2;
200-
LastSwiftMigration = 0920;
197+
LastSwiftMigration = 1010;
201198
ProvisioningStyle = Automatic;
202199
};
203200
29CC29371FF4266D006B6DE7 = {
204201
CreatedOnToolsVersion = 9.2;
202+
LastSwiftMigration = 1010;
205203
ProvisioningStyle = Automatic;
206204
};
207205
};
@@ -250,7 +248,6 @@
250248
29792B141FFAE7FC007A0C57 /* MessageTextView.swift in Sources */,
251249
290482211FED90340053978C /* MessageView.swift in Sources */,
252250
290482261FED90340053978C /* UIButton+BottomHeightOffset.swift in Sources */,
253-
29C8A1FD2187D39200AEA4E0 /* DictionaryString+NSAttributedStringKey.swift in Sources */,
254251
290482251FED90340053978C /* MessageViewDelegate.swift in Sources */,
255252
290482201FED90340053978C /* MessageViewController.swift in Sources */,
256253
29CC29481FF42687006B6DE7 /* UIView+iOS11.swift in Sources */,
@@ -299,13 +296,15 @@
299296
CLANG_WARN_BOOL_CONVERSION = YES;
300297
CLANG_WARN_COMMA = YES;
301298
CLANG_WARN_CONSTANT_CONVERSION = YES;
299+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
302300
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
303301
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
304302
CLANG_WARN_EMPTY_BODY = YES;
305303
CLANG_WARN_ENUM_CONVERSION = YES;
306304
CLANG_WARN_INFINITE_RECURSION = YES;
307305
CLANG_WARN_INT_CONVERSION = YES;
308306
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
307+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
309308
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
310309
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
311310
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -359,13 +358,15 @@
359358
CLANG_WARN_BOOL_CONVERSION = YES;
360359
CLANG_WARN_COMMA = YES;
361360
CLANG_WARN_CONSTANT_CONVERSION = YES;
361+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
362362
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
363363
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
364364
CLANG_WARN_EMPTY_BODY = YES;
365365
CLANG_WARN_ENUM_CONVERSION = YES;
366366
CLANG_WARN_INFINITE_RECURSION = YES;
367367
CLANG_WARN_INT_CONVERSION = YES;
368368
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
369+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
369370
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
370371
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
371372
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -416,7 +417,7 @@
416417
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
417418
SKIP_INSTALL = YES;
418419
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
419-
SWIFT_VERSION = 4.0;
420+
SWIFT_VERSION = 4.2;
420421
TARGETED_DEVICE_FAMILY = "1,2";
421422
};
422423
name = Debug;
@@ -438,7 +439,7 @@
438439
PRODUCT_BUNDLE_IDENTIFIER = com.whoisryannystrom.MessageViewController;
439440
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
440441
SKIP_INSTALL = YES;
441-
SWIFT_VERSION = 4.0;
442+
SWIFT_VERSION = 4.2;
442443
TARGETED_DEVICE_FAMILY = "1,2";
443444
};
444445
name = Release;
@@ -452,7 +453,7 @@
452453
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
453454
PRODUCT_BUNDLE_IDENTIFIER = com.whoisryannystrom.MessageViewControllerTests;
454455
PRODUCT_NAME = "$(TARGET_NAME)";
455-
SWIFT_VERSION = 4.0;
456+
SWIFT_VERSION = 4.2;
456457
TARGETED_DEVICE_FAMILY = "1,2";
457458
};
458459
name = Debug;
@@ -466,7 +467,7 @@
466467
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
467468
PRODUCT_BUNDLE_IDENTIFIER = com.whoisryannystrom.MessageViewControllerTests;
468469
PRODUCT_NAME = "$(TARGET_NAME)";
469-
SWIFT_VERSION = 4.0;
470+
SWIFT_VERSION = 4.2;
470471
TARGETED_DEVICE_FAMILY = "1,2";
471472
};
472473
name = Release;

MessageViewController.xcodeproj/xcshareddata/xcschemes/MessageViewController.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0920"
3+
LastUpgradeVersion = "1010"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

MessageViewController.xcodeproj/xcshareddata/xcschemes/MessageViewControllerTests.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0920"
3+
LastUpgradeVersion = "1010"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

MessageViewController/DictionaryString+NSAttributedStringKey.swift

Lines changed: 0 additions & 19 deletions
This file was deleted.

MessageViewController/MessageAutocompleteController.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public final class MessageAutocompleteController: MessageTextViewListener {
3434
public var appendSpaceOnCompletion = true
3535

3636
/// The text attributes applied to highlighted substrings for each prefix
37-
private var autocompleteTextAttributes: [String: [NSAttributedStringKey: Any]] = [:]
37+
private var autocompleteTextAttributes: [String: [NSAttributedString.Key: Any]] = [:]
3838

3939
/// A key used for referencing which substrings were autocompletes
40-
private let NSAttributedAutocompleteKey = NSAttributedStringKey.init("com.messageviewcontroller.autocompletekey")
40+
private let NSAttributedAutocompleteKey = NSAttributedString.Key.init("com.messageviewcontroller.autocompletekey")
4141

4242
internal var registeredPrefixes = Set<String>()
4343
internal let border = CALayer()
@@ -54,7 +54,7 @@ public final class MessageAutocompleteController: MessageTextViewListener {
5454
notificationCenter.addObserver(
5555
self,
5656
selector: #selector(keyboardWillChangeFrame(notification:)),
57-
name: .UIKeyboardWillChangeFrame,
57+
name: UIResponder.keyboardWillChangeFrameNotification,
5858
object: nil
5959
)
6060
}
@@ -150,15 +150,15 @@ public final class MessageAutocompleteController: MessageTextViewListener {
150150
}
151151
}
152152

153-
public func registerAutocomplete(prefix: String, attributes: [NSAttributedStringKey: Any]) {
153+
public func registerAutocomplete(prefix: String, attributes: [NSAttributedString.Key: Any]) {
154154
registeredPrefixes.insert(prefix)
155155
autocompleteTextAttributes[prefix] = attributes
156156
}
157157

158158
// MARK: Private API
159159

160160
private func insertAutocomplete(_ autocomplete: String, at selection: Selection, for range: NSRange, keepPrefix: Bool) {
161-
let defaultTypingTextAttributes = textView.typingAttributes.attributed
161+
let defaultTypingTextAttributes = textView.typingAttributes
162162

163163
var attrs = defaultTypingTextAttributes
164164
attrs[NSAttributedAutocompleteKey] = true
@@ -200,7 +200,7 @@ public final class MessageAutocompleteController: MessageTextViewListener {
200200
}
201201

202202
@objc internal func keyboardWillChangeFrame(notification: Notification) {
203-
guard let keyboardFrame = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? CGRect
203+
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect
204204
else { return }
205205
keyboardHeight = keyboardFrame.height
206206
}
@@ -233,12 +233,13 @@ public final class MessageAutocompleteController: MessageTextViewListener {
233233
// Only delete the first found range
234234
defer { stop.pointee = true }
235235

236-
let emptyString = NSAttributedString(string: "", attributes: textView.typingAttributes.attributed)
236+
let emptyString = NSAttributedString(string: "", attributes: textView.typingAttributes)
237237
textView.attributedText = textView.attributedText.replacingCharacters(in: range, with: emptyString)
238238
textView.selectedRange = NSRange(location: range.location, length: 0)
239239
})
240240
}
241241
}
242242
}
243-
244243
}
244+
245+

MessageViewController/MessageTextView.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ open class MessageTextView: UITextView, UITextViewDelegate {
2525

2626
open var defaultFont = UIFont.preferredFont(forTextStyle: .body) {
2727
didSet {
28-
defaultTextAttributes[NSAttributedStringKey.font.rawValue] = defaultFont
28+
defaultTextAttributes[.font] = defaultFont
2929
}
3030
}
3131

3232
open var defaultTextColor = UIColor.black {
3333
didSet {
34-
defaultTextAttributes[NSAttributedStringKey.foregroundColor.rawValue] = defaultTextColor
34+
defaultTextAttributes[NSAttributedString.Key.foregroundColor] = defaultTextColor
3535
}
3636
}
3737

38-
internal var defaultTextAttributes: [String: Any] = {
38+
internal var defaultTextAttributes: [NSAttributedString.Key: Any] = {
3939
let style = NSMutableParagraphStyle()
4040
style.paragraphSpacingBefore = 2
4141
style.lineHeightMultiple = 1
42-
return [NSAttributedStringKey.paragraphStyle.rawValue: style]
42+
return [NSAttributedString.Key.paragraphStyle: style]
4343
}() {
4444
didSet {
4545
typingAttributes = defaultTextAttributes
@@ -132,8 +132,8 @@ open class MessageTextView: UITextView, UITextViewDelegate {
132132
addSubview(placeholderLabel)
133133
updatePlaceholderVisibility()
134134

135-
defaultTextAttributes[NSAttributedStringKey.font.rawValue] = defaultFont
136-
defaultTextAttributes[NSAttributedStringKey.foregroundColor.rawValue] = defaultTextColor
135+
defaultTextAttributes[NSAttributedString.Key.font] = defaultFont
136+
defaultTextAttributes[NSAttributedString.Key.foregroundColor] = defaultTextColor
137137
}
138138

139139
internal func enumerateListeners(block: (MessageTextViewListener) -> Void) {

MessageViewController/MessageView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public final class MessageView: UIView, MessageTextViewListener {
131131

132132
/// - Parameter accessibilityLabel: A custom `accessibilityLabel` to set on the button.
133133
/// If none is supplied, it will default to the icon's `accessibilityLabel`.
134-
public func setButton(icon: UIImage?, for state: UIControlState, position: ButtonPosition, accessibilityLabel: String? = nil) {
134+
public func setButton(icon: UIImage?, for state: UIControl.State, position: ButtonPosition, accessibilityLabel: String? = nil) {
135135
let button: UIButton
136136
switch position {
137137
case .left:
@@ -146,7 +146,7 @@ public final class MessageView: UIView, MessageTextViewListener {
146146

147147
/// - Parameter accessibilityLabel: A custom `accessibilityLabel` to set on the button.
148148
/// If none is supplied, it will default to the the supplied `title`.
149-
public func setButton(title: String, for state: UIControlState, position: ButtonPosition, accessibilityLabel: String? = nil) {
149+
public func setButton(title: String, for state: UIControl.State, position: ButtonPosition, accessibilityLabel: String? = nil) {
150150
let button: UIButton
151151
switch position {
152152
case .left:

MessageViewController/MessageViewController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ open class MessageViewController: UIViewController, MessageAutocompleteControlle
9292
messageAutocompleteController.layoutDelegate = self
9393

9494
let notificationCenter = NotificationCenter.default
95-
notificationCenter.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: .UIKeyboardWillShow, object: nil)
96-
notificationCenter.addObserver(self, selector: #selector(keyboardDidShow(notification:)), name: .UIKeyboardDidShow, object: nil)
97-
notificationCenter.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: .UIKeyboardWillHide, object: nil)
98-
notificationCenter.addObserver(self, selector: #selector(keyboardDidHide(notification:)), name: .UIKeyboardDidHide, object: nil)
99-
notificationCenter.addObserver(self, selector: #selector(appWillResignActive(notification:)), name: .UIApplicationWillResignActive, object: nil)
95+
notificationCenter.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
96+
notificationCenter.addObserver(self, selector: #selector(keyboardDidShow(notification:)), name: UIResponder.keyboardDidShowNotification, object: nil)
97+
notificationCenter.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
98+
notificationCenter.addObserver(self, selector: #selector(keyboardDidHide(notification:)), name: UIResponder.keyboardDidHideNotification, object: nil)
99+
notificationCenter.addObserver(self, selector: #selector(appWillResignActive(notification:)), name: UIApplication.willResignActiveNotification, object: nil)
100100
}
101101

102102
internal var safeAreaAdditionalHeight: CGFloat {
@@ -172,8 +172,8 @@ open class MessageViewController: UIViewController, MessageAutocompleteControlle
172172
// MARK: Notifications
173173

174174
@objc internal func keyboardWillShow(notification: Notification) {
175-
guard let keyboardFrame = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? CGRect,
176-
let animationDuration = notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? TimeInterval
175+
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect,
176+
let animationDuration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval
177177
else { return }
178178

179179
scrollView?.stopScrolling()
@@ -211,7 +211,7 @@ open class MessageViewController: UIViewController, MessageAutocompleteControlle
211211
}
212212

213213
@objc internal func keyboardWillHide(notification: Notification) {
214-
guard let animationDuration = notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? TimeInterval
214+
guard let animationDuration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval
215215
else { return }
216216

217217
keyboardState = .hiding

MessageViewControllerTests/MessageTextViewTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class MessageTextViewTests: XCTestCase {
122122
let font = UIFont.systemFont(ofSize: 60)
123123
view.font = font
124124
XCTAssertEqual(view.defaultFont, font)
125-
XCTAssertEqual(view.defaultTextAttributes[NSAttributedStringKey.font.rawValue] as! UIFont, font)
125+
XCTAssertEqual(view.defaultTextAttributes[.font] as! UIFont, font)
126126
}
127127

128128
func test_settingTextColorUpdatesDefaultTextColor() {
@@ -131,7 +131,7 @@ class MessageTextViewTests: XCTestCase {
131131
view.textColor = color
132132
XCTAssertEqual(view.defaultTextColor, color)
133133
XCTAssertEqual(
134-
view.defaultTextAttributes[NSAttributedStringKey.foregroundColor.rawValue] as! UIColor,
134+
view.defaultTextAttributes[NSAttributedString.Key.foregroundColor] as! UIColor,
135135
color
136136
)
137137
}
@@ -167,25 +167,25 @@ class MessageTextViewTests: XCTestCase {
167167
func test_settingDefaultsUpdatesTypingAttributes() {
168168
let view = MessageTextView()
169169
XCTAssertEqual(
170-
view.typingAttributes[NSAttributedStringKey.font.rawValue] as! UIFont,
170+
view.typingAttributes[NSAttributedString.Key.font] as! UIFont,
171171
view.defaultFont
172172
)
173173
XCTAssertEqual(
174-
view.typingAttributes[NSAttributedStringKey.foregroundColor.rawValue] as! UIColor,
174+
view.typingAttributes[NSAttributedString.Key.foregroundColor] as! UIColor,
175175
view.defaultTextColor
176176
)
177177
let font = UIFont.systemFont(ofSize: 60)
178178
let color = UIColor.red
179179
view.defaultFont = font
180180
view.defaultTextColor = color
181181
XCTAssertEqual(
182-
view.typingAttributes[NSAttributedStringKey.font.rawValue] as! UIFont,
182+
view.typingAttributes[NSAttributedString.Key.font] as! UIFont,
183183
font
184184
)
185185
XCTAssertEqual(
186-
view.typingAttributes[NSAttributedStringKey.foregroundColor.rawValue] as! UIColor,
186+
view.typingAttributes[NSAttributedString.Key.foregroundColor] as! UIColor,
187187
color
188188
)
189189
}
190-
191190
}
191+

MessageViewControllerTests/NSAttributedString+HighlightingTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NSAttributedString_HighlightingTests: XCTestCase {
1515
var textView: MessageTextView?
1616

1717
/// A key used for referencing which substrings were autocompletes
18-
private let NSAttributedAutocompleteKey = NSAttributedStringKey.init("com.messageviewcontroller.autocompletekey")
18+
private let NSAttributedAutocompleteKey = NSAttributedString.Key.init("com.messageviewcontroller.autocompletekey")
1919

2020
override func setUp() {
2121
super.setUp()

0 commit comments

Comments
 (0)