A structure used to describe a portion of a series—such as characters in a string or objects in an NSArray object.
Questions tagged [nsrange]
343 questions
-1
votes
1 answer
Xcode:(user defined runtime attribute)Range with minus value. Alternative?
I made a custom UITextField with an additional user defined runtime attribute validRange, which I can set in the storyboard view.
I use this property to check in the EndEditing method to validate the new set text.
I works all fine, till I had to set…

Herr Derb
- 4,977
- 5
- 34
- 62
-1
votes
1 answer
Removing the part of the string
I wanted to get the substrings from the whole string.
NSString *temp = @"Hello World Test";
I wanted to delete the strings from
The final string should be like this - Hello World Test.
I tried to do it…

user2523320
- 13
- 4
-1
votes
1 answer
uitextview shouldChangeTextInRange work in all method
I've input all the 3 methods in - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)string
However, three of the following method can only work 1 of them, I wonder how should the code be written…

zeropt7
- 73
- 1
- 9
-2
votes
2 answers
stringwithformat issue in string searching
I did following experiment. Can any one point out why strings initialized with stringwithformat fail in string searching?
NSString *test1 = @"Hello";
NSString *test2 = @"Hello";
NSString *test3 = [NSString stringWithFormat:@"%@ ",…

user1041086
- 121
- 1
- 3
- 10
-2
votes
2 answers
Intersection of ranges (of floating point ranges)
I am asking a user for four ranges of floating point numbers. I want to check that there is no overlap between them.
If the ranges were integer ranges it seems that I could either create sets or use Swift Range (or NSRange) and check for…

psb
- 89
- 5
-2
votes
2 answers
Find previous and next Range in an array of NSRange
Array of NSRange: [{0, 31}, {32, 29}, {62, 10}, {73, 15}, {89, 0}, {90, 14}, {105, 22}, {128, 26}, {155, 15}, {171, 17}, {189, 22}, {212, 15}, {228, 18}, {247, 3}, {251, 2}, {254, 1}, {256, 0}, {257, 24}, {282, 22}]
myRange: {105, 148}
I have a…

Hassan Taleb
- 2,350
- 2
- 19
- 24
-2
votes
1 answer
How do you bold the first line in an NSMutableParagraphStyle?
I have a class called "rectangle" to make custom UILabels. I override "draw" in the rectangle class. When I instantiate the label, I want the FIRST line of text to show up in bolded font. I know how to solve this by manually getting the range for…

taralee98
- 127
- 1
- 12
-2
votes
1 answer
What is the function of NSRange
I am confused regarding the functionality of NSRange.
What is the function of NSRange in this code?
shouldChangeTextIn range: NSRange

Amy
- 109
- 1
- 1
- 5
-2
votes
1 answer
Is there a situation that when range.location > targetString.length, range.length !=0
Is there a situation possible that when range.location > targetString.length then range.length !=0?
What's the best way to judge whether an range variable exists?

hlily
- 13
- 2
-2
votes
3 answers
Fetch Substring from NSString
I have the following string :
Item 1#Item 2#Item 3#Item 4#Item 5#Item 6#Item 7#Item 8#Item 9#Item 10#Item 11#Item 12#Item 13#Item 14#Item 15#
I want to extract each Item name. How can it be done?

Vaibhav Jhaveri
- 1,579
- 3
- 28
- 53
-2
votes
2 answers
Get NSRange from NSArray
So I have NSArray that contains objects like {117, 22}{http://t.co/7l3oiMDQt3} and I want to get 117 and 22 I tried to use ObjectAtIndex: and the app was crashed and then added this:
if(array.count > 0) {
…

Jon Kayin
- 5
- 3
-2
votes
1 answer
method for Comparing two NSString for spelling mistakes iPhone programming
I am writing an iOS app for a game that is similar to Hangman, except that the player is required to guess the secret word one letter at a time, starting with the first letter. The secret word is displayed as asterisks (*) in a UITextField at the…

user3554683
- 3
- 5
-3
votes
1 answer
How to remove characters from an NSString and replace with spaces?
I have a NSString:
NSString *string1 = @"http://example.com/this-is-an-example-post"
By removing a range of characteres I have substringed it to:
NSString *string2 = @"this-is-an-example-post"
But I am struggling to get it into the form…

Cescy
- 1,921
- 3
- 18
- 21