nsrange Questions

2

Solved

NSRange is just a C struct. I want to create a temporary one in lldb in Xcode at a breakpoint. Specifically for use in NSArray method objectAtIndex:inRange: This does not work. (lldb) expr NSRan...
Tract asked 23/4, 2015 at 23:5

1

Solved

I'm coloring some parts of a text coming from an API (think "@mention" as on Twitter) using NSAttributedString. The API gives me the text and an array of entities representing the parts of the tex...
Heall asked 8/2, 2017 at 13:47

2

I'm attempting to determine the indexes of occurrences of a given string in a String, then generate an NSRange using those indexes in order to add attributes to an NSMutableAttributedString. The pr...
Aeneous asked 4/10, 2015 at 17:44

1

Solved

Hi I'm trying to use addAttribute in Swift3. I want set bold only IDNAME. Here is what I am trying to this. let boldUsername = NSMutableAttributedString(string: "IDNAME hi nice 2 meet you :D #HE...
Touched asked 1/10, 2016 at 8:35

5

Solved

The below function given a NSString, removes the HTML tags from that string and returns the result also as a NSString. private func removeHTMLTags(source: NSString) -> NSString { var range = ...
Honeyhoneybee asked 26/11, 2014 at 18:58

1

Solved

I am using NSRange with an Attributed string, but I don't fully understand which parts of the text will be bolded and which are not. This is what I tried: NSRange boldedRange = NSMakeRange(2...
Northumberland asked 29/12, 2015 at 17:53

2

Solved

I need to split a string into 2-letter pieces. Like “friend" -> "fr" "ie" "nd". (Okay, its a step for me to change HEX string to Uint8 Array) My code is for i=0; i<chars.count/2; i++ { let ...
Colima asked 15/12, 2015 at 1:36

4

Solved

I have two NSStrings: orgText and searchLetter. I want to highlight every occurrences of the searchLetter in the orgText with a red color. How can I get the NSRange of all occurrences of the search...
Manual asked 16/12, 2011 at 11:44

2

Solved

When I try to extract a string from a larger string it gives me a range or index out of bounds error. I might be overlooking something really obvious here. Thanks. NSString *title = [TBXML textFor...
Peacetime asked 18/5, 2011 at 23:32

3

Solved

I am getting the following index out of bounds error: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty ...
Edvard asked 23/11, 2011 at 9:17

4

Solved

I'm trying to use NSRange to hold a range of years, such as NSRange years = NSMakeRange(2011, 5); I know NSRange is used mostly for filtering, however I want to loop over the elements in the ran...
Desimone asked 30/11, 2011 at 4:2

1

Solved

I want to check if a string contains only numerals. I came across this answer written in Objective-C. NSRange range = [myTextField.text rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]]...
Calycle asked 11/8, 2014 at 10:32

2

Say my range is created as NSRange myRange = {0,100}; How do I print myRange in NSLog? The following is not working NSLog(@"my range is %@",myRange);
Alan asked 8/8, 2014 at 21:53

4

Solved

I've just started learning Objective-C and made a little compass app that will display a direction when it falls into a range of headings. It works just fine, but I wonder if there is a more concis...
Coagulum asked 9/11, 2010 at 21:56

3

Solved

I have an Array with content. as usual it contain 20 objects. I want the same array split into 2 sections in Tableview. I am trying to implement it with NSMake in current array. For example I need ...
Debra asked 25/10, 2013 at 18:29

3

Solved

I have a collection of int64_t values that I need to make an index set out of. I previously have used: NSIndexSet *set = [NSIndexSet indexSetWithRange:NSMakeRange(location, length)]; to make in...
Cordiecordier asked 17/10, 2013 at 15:1

1

Solved

I try to assign attributes to 3 last chars of newClock string, which is @"3:33:23". However I get an error when construct NSRange: NSMutableAttributedString *mas = [[NSMutableAttributedString all...
Phox asked 13/10, 2013 at 11:28

3

Solved

I have the following NSString: Hello (my name is) John How do I remove the (my name is) part quickly and easily? I want to make sure it handles situations where there is only a ( and then a foll...
Siu asked 4/6, 2013 at 19:52

3

Solved

I'm going through some older code in one of my apps and fixing up the code in areas that could be potentially problematic. I'm seeing a lot of old code using... NSRange range = //determine range ...
Wristband asked 10/10, 2012 at 20:30

2

Solved

I'm trying to add some fancy text to a label, but I've run into some problems with the NSMutableAttributedString class. I was trying to achieve four this: 1. Change font, 2. Underline range, 3. Cha...
Godgiven asked 20/7, 2012 at 2:15

1

Solved

I want to implement a delete key for my calculator app. My pseudocode for this was: foo = length of current number bar = length of current number-1 current number = current number with character ...
Kookaburra asked 19/7, 2012 at 18:25

2

Solved

I am working on a Cocoa Mac OSX app, and I am wondering if it is possible to present the contents of an NSRange found by: NSRange range; range.location = 4; range.length = 4; as an NSString? e....
Sideslip asked 29/5, 2012 at 18:51

1

Solved

I am getting the error below, which makes no sense. * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSMutableArray removeObjectsInRange:]: range {11, 15} extends bey...
Isabelleisac asked 26/3, 2012 at 20:46

1

Solved

I have a string! NSString *myString=[NSString stringWithFormat:@"This is my lovely string"]; What I want to do is: Assuming the first character in the string is at index 0. Go to the 11th cha...
Ashling asked 7/12, 2011 at 15:48

1

Solved

I stumbled across the following and can't seem to work out why this works. Please can you explain why I don't need to use a pointer before range? NSString *d = @"The quick brown fox"; NSRange ran...
Tanto asked 30/11, 2011 at 23:18

© 2022 - 2024 — McMap. All rights reserved.