• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSScanner know-how
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScanner know-how


  • Subject: Re: NSScanner know-how
  • From: Jérôme Laurens <email@hidden>
  • Date: Thu, 24 Jul 2003 00:22:58 +0200

Le jeudi, 24 juil 2003, ` 00:02 Europe/Zurich, Sanri Parov a icrit :

> Hi everybody,
>
> I'm in little trouble with NSScanner, just because it's not well
> documented IMHO in the developer docs.
> Given this puny little source text:
>
> #id:15;
> #customer:F.lli Remari;
> #phone:123456789;
> #cell:13456;
> #fax:987987;
> #id:16;
> #customer:Zanovello Nicola;
> #phone:456789;
> #cell:;
> #fax:12356;
>
> I'd like to import the right-values to some variables.
> Here's the source I've done by copying the example from the docs...
>
> NSString* id_origin = @"#id:";
> NSStrign* id_sql;
> NSCharacterSet *semicolonSet;
> NSScanner *scanner;
> semicolonSet = [NSCharacterSet
> characterSetWithCharactersInString:@";"];
> scanner = [NSScanner scannerWithString:stringa_da_file];
>
>
> while ([scanner isAtEnd] == NO)
> {
> if([scanner scanString:id_origin intoString:NULL] && [scanner
> scanUpToCharactersFromSet:semicolonSet intoString:&id_sql] && [scanner
> scanString:@";" intoString:NULL])
> NSLog(@"%@",id_sql);
> }
>
>


replace your test by
> if([scanner scanString:id_origin intoString:NULL] && ([scanner
> scanUpToCharactersFromSet:semicolonSet intoString:&id_sql], [scanner
> scanString:@";" intoString:NULL]))
> NSLog(@"%@",id_sql);

this will prevent the problem of the line

> #cell:;
>

where scanner
> scanUpToCharactersFromSet:semicolonSet intoString:&id_sql]

would return NO because it has nothing to scan to reach the :
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSScanner know-how
      • From: Sanri Parov <email@hidden>
References: 
 >NSScanner know-how (From: Sanri Parov <email@hidden>)

  • Prev by Date: Re: flummoxed by math failure
  • Next by Date: Re: Dockless app?
  • Previous by thread: NSScanner know-how
  • Next by thread: Re: NSScanner know-how
  • Index(es):
    • Date
    • Thread