• 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 Madness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScanner Madness


  • Subject: Re: NSScanner Madness
  • From: Shawn Erickson <email@hidden>
  • Date: Mon, 6 Dec 2004 23:03:34 -0800


On Dec 6, 2004, at 10:05 PM, Malte wrote:

Hey *,

i've been trying, reading and searching for a while now but can't figure it out by myself.
Problem:
I have an NSMutableString * read
I have an NSDictionary * table
I have an NSMutableString * translation


"table" consists of entries like these:

[table setObject:@"mySpecialCharacter" forKey:@"regularCharacter"];

So now what i'm obviously trying to do is to scan an entire string (as entered by the user into an NSTextField) and iterate over each character of it, translating it from the "regularCharacter" that is still is, into the "mySpecialCharacter" that i need it to be.
So somehow i need my NSScanner to grind through the entire string, look at each character as an NSString object, look up its equivalent value in my NSDictionary and write that value into my translation string which shall finally be displayed to the user.
8(
I just can't figure it out myself. It'd be absolutely awesome if anyone feels like cranking out a few lines of code or possibly spin my eyeballs onto a nifty tutorial somewhere. Oh..and please don't say "look at the NSScanner doc, it's all right there".
I've absolutely stared at every pixel of it and still.......can't figure it out. :'-(


Thanks a lot.

Don't use NSScanner? Why not simply iterate over the characters in the string and convert them as needed (-characterAtIndex:).


Of course regardless of what you do be ready to deal with decomposed characters (you may be able to normalize the string first... -precomposedStringWithCanonicalMapping, etc. ...but this side of things isn't in my experience base).

-Shawn

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSScanner Madness
      • From: Malte <email@hidden>
References: 
 >NSScanner Madness (From: Malte <email@hidden>)

  • Prev by Date: NSScanner Madness
  • Next by Date: Re: [[NSNotificationCenter defaultCenter] postNotificationName:...] in a C function get error
  • Previous by thread: NSScanner Madness
  • Next by thread: Re: NSScanner Madness
  • Index(es):
    • Date
    • Thread