Type 'String.Index' does not conform protocol '_Strideable'
You have to check if the range is not nil
if value.range(of: formatter.minusSign) != nil {
//STH
}
or – preferable if you want to use the range – optional bindings
if let range = value.range(of: formatter.minusSign) {
// do somthing with the range
}
or simply
if value.contains(formatter.minusSign) {
//STH
}
Type 'String.Index' does not conform protocol 'IntegerLiteralConvertible'
In beta 4, Swift's String.Index handling changed yet again -- you now can't supply an Int
when a String.Index
is expected. The way to handle it is by creating the String.Index
you need using the advance
method:
if !name.isEmpty {
var splitted: [String] = name.componentsSeparatedByString(" ")
for curPart in splitted {
if !curPart.isEmpty {
acronym += curPart.substringToIndex(advance(curPart.startIndex, 1))
}
}
if countElements(acronym) > 2 {
acronym = acronym.substringToIndex(advance(acronym.startIndex, 2))
}
}
This is all based on making sure Unicode strings are handled properly - since different Unicode characters can have different sizes, pure integer indexing would hide the fact that Strings aren't random access.
Swift 3.1 UITextField Type 'String.Index' (aka 'String.CharacterView.Index') does not conform to protocol '_Strideable'
I ran into the same problem recently and the solution that worked for me was to check if non of the characters match the inverted set of my allowed characters rather than to check if all characters match the allowed characters set. Below piece of code worked perfectly for me.
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let allowedCharacterSet = CharacterSet.letters
if string.isEmpty {
return true
} else if string.rangeOfCharacter(from: allowedCharacterSet.inverted) != nil { //check if the input contains anything else than letters
return false
} else {
return true
}
}
Type 'VideoView' does not conform to protocol 'UIViewRepresentable'
Remove some
from return type
func makeUIView(context: Context) -> WKWebView { // << here !!
return WKWebView()
}
Related Topics
Get the Callers Phone Number from an Incoming Call on Iphone
Universal Link Broken in iOS 11.2
How to Change a Swiftui Color to Uicolor
Firebase Dynamic Link Always Goes to App Store Url Even If the App Is Installed
Xcode Error:Distill Failed for Unknown Reasons
How to Properly Remove Node When Out of Screen Bounds
How to Save Tableview Cell's Checkmark After Reload View Use Nsuserdefaults
Non-Nominal Type X Does Not Support Explicit Initialization
Best Analytics Offering for Iphone
Checking Push Notification Registration: Isregisteredforremotenotifications Not Updating
Swift Error: Editor Placeholder in Source File
Static VS Class as Class Variable/Method (Swift)
What's Wrong Here: Instance Member Cannot Be Used on Type