>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