Previously, when you wanted to see if your Swift string contained another string, you would cast it to a NSString and call .containsString. Apple, in their infinite wisdom, made this version-aware, so if you try it under S2 it will demand a #available wrapper even if your target platform does support it (which I guess is a bug).
1
There are 1 best solutions below
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in NSSTRING
- Exact Swift replacement for NSString's boolValue method?
- How can I identify all nodes whose name begins with "square" and ends with a number like "square1", "square2", etc inside of a child nodes with name?
- How to correctly handle UTF-8 strings in XCode Objective-C program with multiple inputs?
- Why NSString floatvalue return 0 for "NaN"?
- Get NSHomeDirectory() in pure C
- Working with NSString manipulating special characters
- 'NSString initWithFormat' can't print chinese correctly
- Add degree sign to a label with different font sizes - Swift
- How to show JSON response in iPhone using the objective c by dynamically adding " \" to the keys?
- stringByRemovingPercentEncoding resulting in null string
- What is the difference between String and NSMutableString?
- Easiest way to perform a deep copy of a string to pass to a scanner?
- Looking for simple example to write text into a NSImage using Cocoa
- How to remove last path of NSURL with special characters
- Is there any way to map dictionary of type [NSString: Any] to another [String: Any]
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
So the best solution appears to be this:
and now to check it, instead of this:
you get to use the much nicer looking:
This no longer complains about the version, and (IMHO) looks better too. You almost certainly want this too:
Apple keeps changing the way you get length, and I hope that any future changes to the API will be
#available-able, at which point.lengthcan be easily modified. And these are just for sanity: