Questions tagged [nsscanner]

The NSScanner class is an Objective-C class implemented in the Foundation framework, starting from Mac OS X 10.0. The NSScanner is a highly configurable tool designed for extracting substrings and numeric values from loosely demarcated strings.

The NSScanner class is an abstract superclass of a class cluster that declares the programmatic interface for an object that scans values from an NSString object.

An NSScanner object interprets and converts the characters of an NSString object into number and string values. You assign the scanner’s string on creating it, and the scanner progresses through the characters of that string from beginning to end as you request items.

Because of the nature of class clusters, scanner objects aren’t actual instances of the NSScanner class but one of its private subclasses. Although a scanner object’s class is private, its interface is public, as declared by this abstract superclass, NSScanner. The primitive methods of NSScanner are string and all of the methods listed under Configuring a Scanner. The objects you create using this class are referred to as scanner objects (and when no confusion will result, merely as scanners).

You can set an NSScanner object to ignore a set of characters as it scans the string using the charactersToBeSkipped property. Characters in the skip set are skipped over before scanning the target. The default set of characters to skip is the whitespace and newline character set.

To retrieve the unscanned remainder of the string, use [[scanner string] substringFromIndex: [scanner scanLocation]].

146 questions
0
votes
1 answer

Search a string for an occurrence of characters of other string

I have two NSString, for example: stringOne = @"1760254913042013"; stringTwo = @"4917602549030391"; I need to compare both strings to find out if both have some string in common. In the example this common string would be @"17602549". Trying to…
0
votes
1 answer

nsscanner limiting output to interface

I am trying out a nifty obj-c/ios app i found at http://tech.pro/tutorial/975/building-an-earthquake-monitor-for-iphone-using-mapkit. It maps out earthquakes It works fine, but I wanted add title and subtitle to the pins. No go. The problem appears…
David
  • 23
  • 3
0
votes
1 answer

Using NSScanner to scan multiple lined text file

I have experience with Java and Android development, and am now attempting to learn Objective-C and iPhone/iPad development. In order to help teach myself, I am re-writing an application I made for android over to iPhone. The specific problem I am…
bmjohns
  • 6,344
  • 1
  • 33
  • 39
0
votes
2 answers

NSScanner scan a string from end

I have a filename like this WO.NO 193 AND TASK NO 15146.JPG. I want to split out the extension from the filename. Can someone tell how could i do this with NSSCanner, is there any other way than using the scanner. If so please let me know the…
Karthick
  • 382
  • 1
  • 3
  • 23
0
votes
1 answer

search string starts and ends with in a multiple occurance of same string

I appoligize for the same question but i didnt got the answer i was trying for 2 days m not getting it , can any one help me . i need to find and print only the string which starts and ends with "&". but in my string lots of same occurance of "&"…
Diaaaaan
  • 35
  • 6
0
votes
0 answers

filter starts with abc# and ends with # objective c

I'm new and this is my first post. In my Inputstream I am getting list of message in where I have to filter a specific line and and to print that line, but some time its get crashed, can any one tell me where I'm making my mistake? Here is my…
Diaaaaan
  • 35
  • 6
0
votes
1 answer

Quicker Way To Extract Text From Website?

My app parses an online XML file. I am trying to add a feature that will scan the LINK from each item in the xml for certain keywords, and return them to an NSString. I set it up to do this when it parses using: NSString *string = [NSString…
user717452
  • 33
  • 14
  • 73
  • 149
0
votes
5 answers

Replacing instances of a character with two different characters in Objective-C

I have a huge amount of NSStrings in a database that get passed to a view controller in an iOS app. They are formatted as "This is a message with $specially formatted$ content". However, I need to change the '$' at the start of the special…
Sarreph
  • 1,986
  • 2
  • 19
  • 41
0
votes
1 answer

NSScanner unrecognized selector on scanUpToString

I use the URL parser class from Dimitris but i encounter a problem when init object trought initWithURLString: - (id) initWithURLString:(NSString *)url{ self = [super init]; if (self != nil) { NSString *string = url; …
ApheX
  • 685
  • 2
  • 10
  • 26
0
votes
1 answer

Issue with GLTapLabel + certain chars don't get drawn

I'm using GLTapLabel for a project and almost everything is working fine. When I try to show a text starting with a + or any other special characters, the whole thing looks like this: Screenshot 1 (left: the output in the simulator, right: the text…
Nicolai
  • 328
  • 2
  • 10
0
votes
1 answer

NSScanner scan after equal sign

oauth_token=requestkey&oauth_token_secret=requestsecret How can I use NSScanner to get "requestkey" and "requestsecret". I can't seem to achieve it. NSScanner* scanner = [NSScanner scannerWithString:string]; NSString *oauth_token =…
Hexark
  • 413
  • 6
  • 22
0
votes
2 answers

Extracting an NSString from both Parenthesis and Quotations

I have a string that is returned from a WebAPI call that looks like this: ( "username@domain.com" ) As a workaround, I am trying to extract just the email address i.e. username@domain.com I am not sure what the best approach to do this…
Jeremy
  • 161
  • 2
  • 12
0
votes
1 answer

Remove Link on Images only in HTML of iPhone

I parse an XML and use different elements from the xml to build some HTML code that I can then show in a UIWebView. One part of the Parsed XML includes pictures with links. I would like to keep the pictures, but lose the links. Normally I could…
user717452
  • 33
  • 14
  • 73
  • 149
0
votes
1 answer

How do i read information from a .txt file into an NSMutable array in Xcode (first line contains string, second integer, third another string, etc)

I need help reading in a .txt file into a NSMutableArray in Xcode. I want to read in a large file containing many different strings and integers in a specific order, then I want to create a new person object with the information read in and add each…
0
votes
3 answers

NSScanner scanUpToCharactersFromSet gives BAD ACCESS

NSString*test=[NSString stringWithString:inputString]; NSScanner*scan; BOOL pass= [scan scanUpToCharactersFromSet:[[NSCharacterSet alphanumericCharacterSet] invertedSet] intoString:&test]; The last line crashes the app with bad access. Does it…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
1 2 3
9
10