BSD

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • NSScanner isAtEnd

    0 answers - 1179 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    >From your description it sounds like you only need to read one single double
    from the text field. There is no need for the while loop, just get rid of
    it. Also you could set a formatter on the text field to only accept digits
    and simple use the NSString method doubleValue.
    double x = [[theTextView string] doubleValue];
    to ignore non-digits do:
    NSString *textViewContents = [theTextView string];
    double x = 0.0;
    NSScanner *doubleScanner = [NSScanner ];
    [doubleScanner setCharactersToBeSkipped:[[NSCharacterSet
    decimalDigitCharacterSet] invertedSet]];
    BL gotDouble;
    gotDouble = [doubleScanner scanDouble:&x];
    if (gotDouble) {
    if (5.5 == x) {
    NSLog(@"x was correctly extracted");
    }
    NSLog(@"double extracted: %f", x);
    }
    else {
    NSLog(@"Double not extracted");
    }
    Jack Frost
    http://www.bruji.com/
    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com
    This email sent to bsdarchive (AT) developershed (DOT) com

Re: NSScanner isAtEnd


max 4000 letters.
Your nickname that display:
In order to stop the spam: 9 + 8 =
QUESTION ON "BSD"

EMSDN.COM