Questions tagged [nsrange]

A structure used to describe a portion of a series—such as characters in a string or objects in an NSArray object.

343 questions
0
votes
1 answer

Finding the location (index) of a NSRange in NSArray using ObjectAtIndex

I'm trying to find this NSRange location (index) in a NSArray: NSValue *findRangeValue = [NSValue valueWithRange:NSMakeRange(146, 143)]; I'm able to find the location using the method indexOfObject: NSUInteger integer = [mutArray…
0
votes
2 answers

Create an NSMutableArray of NSRange's and properly read the range values later

I am trying to create an NSMutableArray of the ranges discovered from NSRegularExpression, but I cannot get the NSMutableArray to hold objects. Help? Declare the array by: NSMutableArray *matches = [[NSMutableArray alloc]init]; At the end of my…
0
votes
3 answers

substringWithRange out of bounds--what am I missing?

I'm trying to extract some strings from some code, and I'm coming up against an NSRangeException I don't understand. Here's my code: NSString *start = @""; NSString *end = @" "; NSRange startRange =…
Joel Derfner
  • 2,207
  • 6
  • 33
  • 45
0
votes
2 answers

NSMutableAttributedString with NSRange issue

I have the following string 22\nShaʻban\n1435 and i'm using NSMutableAttributedString to format the above string using multiple fonts as follows: NSString* orgString=@"22\nShaʻban\n1435"; NSMutableAttributedString…
Eslam Hamdy
  • 7,126
  • 27
  • 105
  • 165
0
votes
1 answer

NSRange changes itself inside for loop

I have an NSDictionary of NSRange objects, with keys for their index in the array. I am attempting to use each of these ranges to create substrings of a larger string, and place each of these substrings in the array. I basically have this completed,…
arc4randall
  • 3,275
  • 3
  • 27
  • 40
0
votes
1 answer

Exclude "@" sign from punctuationCharacterSet

I am trying to filter my attributedString this way, using this code. However, I want the rangeOfCharacterFromSet: to include all of its original values EXCEPT for the "@" sign. How would I do this? NSRange rangeSpace = [filteredText…
user2284295
0
votes
2 answers

Scroll textview when selecting text cover whole textview's screen area

In my application there is one UIScrollView having UITextView. if the UITextView has 200 lines and user will select the first line and drag the last end point of selected text and user will drag that point to select more lines. then, in a screen…
Sam
  • 431
  • 7
  • 23
0
votes
3 answers

Not allowing user to enter the number 1 as the first digit in a UITextField

I have a UITextField where the user can enter in their phone number. I need the phone number to be in the following format: 5567289223 and not like this with an extra 1 at the beginning: 15567289223. I already have an if statement setup so if the…
user3344977
  • 3,584
  • 4
  • 32
  • 88
0
votes
3 answers

How do you get the substring using 2 encapsulating characters?

How do we get a substring from : NSString *string = @"exmple string [image]"; where we want to extract the string in between "[" and "]". I was thinking of using NSRange with: NSRange rangeStart = [title rangeOfString:@"["…
Frank
  • 3,073
  • 5
  • 40
  • 67
0
votes
2 answers

NSString Range how it works?

I'm just playing around with Xcode, and now using Xcode to find some string in another string. And problem here is that it doesn't show what I expect. (It shows "No match found!") Any tips, please? Thanks, And my code is : int main(int argc, const…
Toshi
  • 6,012
  • 8
  • 35
  • 58
0
votes
1 answer

Is it possible to call "location" on rangerOfCharacterFromSet without dot notation in objective-c?

I am trying to write this without dot notation but can't figure it out: [[textField text] rangeOfCharacterFromSet:someInstanceVar].location I keep getting bad receiver type NSRange (aka '_struct NSRange') Is this not possible? Kind regards
LondonGuy
  • 10,778
  • 11
  • 79
  • 151
0
votes
2 answers

How to extend search with SearchBar

I want to search through an array with strings in it. Therefore i use a searchbar. Here's my code: for(NSString *string in itemsArray) { NSRange nameRange = [string rangeOfString:text options:NSCaseInsensitiveSearch]; if (nameRange.location !=…
user3298017
  • 31
  • 1
  • 6
0
votes
1 answer

iOS: Why does NSRange always throw error "use of undeclared identifier"?

These lines of code are the problem: case CostPeriodMonthly: NSRange days = [gregorian rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:[NSDate date]]; [endDateComponents setDay:days.length]; …
MichiZH
  • 5,587
  • 12
  • 41
  • 81
0
votes
1 answer

Comparing NSString to NSTextView Range prior to Appending

Coding in Objective-C, I'm appending text to a NSTextView object named subCap in my code like so: [[[_subCAP textStorage] mutableString]appendString:[NSString stringWithFormat:@"%@", subcapLine]]; subcapLine will have two timecode values such as:…
ConleeC
  • 337
  • 6
  • 13
0
votes
1 answer

rangeOfString method call causing unrecognized selector error

I am accessing the address book contacts, and then running a for loop on all of the contacts. The loop's main purpose is to access the First Name and Phone Number values of the user's address book contacts and place those values into NSString…
user3117509
  • 833
  • 3
  • 14
  • 32