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
2 answers

printing all names seperated by comma - need efficient way

I have string as below. imageFinalNames = @"car1389188719-1224596-22.jpg,car1389188659-1224536-22.jpg,car1389188311-1224187-22.jpg,car1389187911-1223788-22.jpg,"; I want to print all those names separately. I want result as…
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
0
votes
2 answers

Checking whether or not a UITableView cell contains a keyword

I was trying to see if a UITableView cell contains a string. I have tried using: if ([cell.textlabel.text rangeOfString:@"Ok"].location !=NSNotFound) { } But that was no use. It found the text every time no matter what.
0
votes
2 answers

How to extract substring from a string in ios?

I know this is one of the most asked question , but I am not getting how to acually do this. Here is my string ====> @"latitude - 51.50998000 , longitude - -0.13370000". and I want to extract only the numeric values from it. How can this be…
iCodes
  • 1,382
  • 3
  • 21
  • 47
0
votes
1 answer

NSRange length change to 0

I have this code: for (TFHppleElement *element in htmlNodes) { if (![element.tagName isEqual:@"img"]) { NSString *elementHtmlCode = htmlCode; if (element.text != nil) { NSString *elementText = element.text; …
Samael
  • 21
  • 4
0
votes
3 answers

Full Length URL "edit" using NSMakeRange

I'm trying to cut a URL down from this: http://www.huffingtonpost.com/2013/08/01/edward-snowden-russia_n_3688225.html to this: http://www.huffingtonpost.com/ using NSMakeRange(Location, Length) My code: if ([URLContainer hasPrefix:@"http://www."])…
0
votes
1 answer

NSAttributedString not getting range properly?

I found this bit of code here on StackOverflow to highlight a keyword in a UITextView -(IBAction) highlight:(id) sender{ NSMutableAttributedString * string = [[NSMutableAttributedString alloc]initWithString:self.text.text]; NSArray…
0
votes
2 answers

Method that finds an exact word within an attributed string

I am looking for an Objective-C method that will find a specific word within a string. I was using: - (NSRange)rangeOfString:(NSString *)aString but it's not doing exactly what I want. The reason why is that I am looking more for a token match than…
BlueBear
  • 7,469
  • 6
  • 32
  • 47
0
votes
3 answers

Search for any characters in an NSString

I have the following code to search an NSString: for (NSDictionary *obj in data) { NSString *objQuestion = [obj objectForKey:@"Question"]; NSRange dataRange = [objQuestion rangeOfString:searchText options:NSCaseInsensitiveSearch]; …
user1445205
0
votes
1 answer

split NSMutableAttributedString in half category

I am having some issues with my category for splitting an NSMutableAttributedString in half it crashes on the NSMakeRange(...) #import @interface NSMutableAttributedString (StringSplit) - (NSMutableAttributedString…
David Karlsson
  • 9,396
  • 9
  • 58
  • 103
0
votes
1 answer

getting multiple integer values out of textfield

I want to read many different integer values out of an textfield and for that I have this code: NSString *string1,*string2; string1= [textField stringValue]; int i,c; c=0; NSInteger values[50]; for (i=0; i<50; ) { string2=[NSString…
killerwakka
  • 31
  • 2
  • 9
0
votes
2 answers

Is it necessary to Swap the bytes in this scenario in Objective-c?

I stored the data bytes in an Array. Now, in the program I used getBytes:range:NSmakeRange(position, length). When I printed my received bytes I think their position got swapped and my answer was 0x0292 instead of 0x9202 (check my program…
Raj0689
  • 73
  • 1
  • 1
  • 9
0
votes
3 answers

Get substring from string in iphone

I have a string like this \"Marco

Herrera is currently on national team duty…

user2268539
  • 173
  • 2
  • 3
  • 14
0
votes
3 answers

How to properly take out a string from a string?

I have a NSString that looks something like this "ALAssetsGroup - Name:Hej - ProgCam, Type:Album, Assets count:0" I want to "extract" the name "Hej". I tried to do it like this: NSString *sStr = [NSString stringWithFormat:@"%@",…
Arbitur
  • 38,684
  • 22
  • 91
  • 128
0
votes
1 answer

App crashes with 'NSRangeException' when library is empty

I am using this code to get the latest photo from the cameraRoll: - (void) getTheLatestPhoto{ ALAssetsLibrary *cameraRoll = [[ALAssetsLibrary alloc] init]; [cameraRoll enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos…
0
votes
1 answer

Getting Substring with NSRange

I try to read out the url's of youtubevideos from this link: http://gdata.youtube.com/feeds/api/videos?author=channelname I tried it like this: NSRange startRange = [ret rangeOfString:@"
Phil
  • 646
  • 1
  • 8
  • 23