Skip to content

Support for Swift 4 #7

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

Merged
merged 1 commit into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SelectableTextView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
Expand All @@ -583,7 +583,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.guaranteed.SelectableTextView;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Source/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal extension Character {
internal extension String {

var length: Int {
return characters.count
return count
}

func truncate(leadingCharacters: Int) -> String {
Expand Down
6 changes: 3 additions & 3 deletions Source/TextCellModelFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ final internal class TextCellModelFactory {
}

let text = attributedText.string
guard text.characters.count > 0 else {
guard text.count > 0 else {
return textModels
}

var characterCount: Int = 0
var currentTextChunkStart = 0
var currentTextChunkType = TextType.fromCharacter(character: text[text.startIndex])
typealias _Index = String.CharacterView.Index
typealias _Index = String.Index

func addModelAtIndex(index: _Index) {
let currentTextChunkEnd = characterCount
Expand Down Expand Up @@ -80,7 +80,7 @@ final internal class TextCellModelFactory {
currentTextChunkStart = currentTextChunkEnd
}

for index in text.characters.indices {
for index in text.indices {
let currentCharacterTextType = TextType.fromCharacter(character: text[index])
if currentTextChunkType != currentCharacterTextType {
addModelAtIndex(index: index)
Expand Down
2 changes: 1 addition & 1 deletion Source/TextSelectionValidator/RegexValidators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fileprivate final class Regex {
}

func test(input: String) -> Bool {
let matches = self.internalExpression.matches(in: input, options: [], range: NSMakeRange(0, input.characters.count))
let matches = self.internalExpression.matches(in: input, options: [], range: NSMakeRange(0, input.count))
return matches.count > 0
}
}
Expand Down