nsrange Questions
2
I am setting the attributed text of a label, and I am getting this strange error:
Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray replaceObjectsInRange:wit...
Frankie asked 23/8, 2013 at 19:55
3
Solved
I have an NSMutatableString:
var string: String = "Due in %@ (%@) $%@.\nOverdue! Please pay now %@"
attributedText = NSMutableAttributedString(string: string, attributes: attributes)
How to calc...
2
Solved
I have AttributedString with emoji like this "🤣🤣🤣 @Mervin tester 🤣🤣🤣"
Now I need to find a range of Mervin in this attributed String.
let attributedString = NSMutableAttributedString(strin...
Lysias asked 29/6, 2017 at 8:24
10
Solved
I'm using shouldChangeCharactersInRange as a way of using on-the-fly type search.
However I'm having a problem, shouldChangeCharactersInRange gets called before the text field actually updates:
I...
Sharp asked 2/9, 2014 at 10:43
7
Solved
I need to find the pixel-frame for different ranges in a textview. I'm using the - (CGRect)firstRectForRange:(UITextRange *)range; to do it. However I can't find out how to actually create a UIText...
Hampshire asked 3/2, 2012 at 9:53
16
Solved
How can I convert NSRange to Range<String.Index> in Swift?
I want to use the following UITextFieldDelegate method:
func textField(textField: UITextField!,
shouldChangeCharactersInRange r...
13
Solved
Problem: NSAttributedString takes an NSRange while I'm using a Swift String that uses Range
let text = "Long paragraph saying something goes here!"
let textRange = text.startIndex..<text.endInd...
2
I'm using this method for converting a NSRange to a CGRect as it relates to a UITextView:
- (CGRect)frameOfTextRange:(NSRange)range inTextView:(UITextView *)textView
{
UITextPosition *beginning =...
Kesterson asked 1/9, 2014 at 11:9
4
Solved
I need to implement experience filter like this
0 to 2 years
2+ to 4 years
How to express it in swift range?
Problem is I can't express more than 2 to 4 years. While I can do less than upper ...
3
Solved
I am accepting an NSString of random size from a UITextField and passing it over to a method that I am creating that will capture only the last 4 characters entered in the string.
I have looked th...
9
Solved
I have a UILabel I've made programmatically as:
var label = UILabel()
I've then declared some styling for the label, including a font, such as:
label.frame = CGRect(x: 20, y: myHeaderView.frame.he...
4
Solved
How can I convert a UITextRange object to an NSRange? I've seen plenty of SO posts about going the other direction but that's the opposite of what I need. I'm using the UITextRange selectedTextRang...
Addlebrained asked 15/1, 2014 at 22:38
1
Solved
I use a UITextView with text attributes editing enabled and I am having issue with getting the attributes when there are emojis in the text.
Here is the code I use:
var textAttributes = [(attribute...
Spanking asked 6/6, 2019 at 3:59
2
Solved
In my application, I have some code to fetch the range of the host in a URL. It looks like this:
private func rangeOfHost(text: String) -> NSRange? {
let url = URL(string: text)
if let host: ...
6
Solved
Is there a short way to say "entire string" rather than typing out:
NSMakeRange(0, myString.length)]
It seems silly that the longest part of this kind of code is the least important (because I u...
Anaesthesia asked 25/2, 2013 at 8:0
3
Say I pass the NSRange of (location: 5, length: 50) on the NSString "foo", that range obviously doesn't exist.
Is there a way to say [string rangeExists:NSRange] for instance, or do we have to ma...
Barnie asked 9/12, 2015 at 22:29
2
Solved
Is there any difference between:
NSRange(location: 0, length: 5)
and:
NSMakeRange(0, 5)
Because Swiftlint throws a warning when I use NSMakeRange, but I don't know why.
Thanks for the Help ...
2
Getting this error when checking the range for string characters...
@objc func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -&g...
4
Solved
In my application I need to set Read more into the text view if text input is large.so my approach is to find the range of string that would fit in the text view and append See More to it.Is there ...
Festinate asked 22/1, 2015 at 7:20
1
Solved
Did someone can give me a hint which property of a Range is the equivalent property to the location property of an NSRange.
Especially I'm interested how I would migrate the following line of code...
2
Solved
I have an NSRange and need to break a string into two substrings on either side of this NSRange. How do I get an integer value (like the index) out of an NSRange?
Interlay asked 27/8, 2012 at 14:50
3
Solved
I Have a error in my code like "Cannot convert value of type 'NSRange' (aka '_NSRange') to expected argument type 'Range' (aka 'Range')" but I don't know how to solve this please any one help me?
...
1
Solved
What is the Swift constructor for the code below?
NSMakeRange(0, textfield.text!.characters.count)
2
Solved
I am using the following code to get a String substring from an NSRange:
func substring(with nsrange: NSRange) -> String? {
guard let range = Range.init(nsrange)
else { return nil }
let star...
1
Solved
I have the code below, which works in swift 2.3. I am struggling to understand how to convert it to swift 3/4 - the issue it those is
Value of type 'Range<Int>' has no member 'map'
let gra...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.