Hi,

I've been playing with NSScanner to cut a string eg: this is a test " So is this"test from a search field into its components. ie. extract the quoted text to be placed into an array as well as the other components, pre and post quoted text. The other components will eventually be split with componentsSeparatedByString.

My issue is that if I paste the above text into the search field, all is OK. But if I type in- "test as a test case, it locks up and fails with The Debugger has exited due to signal 11 (SIGSEGV).The Debugger has exited due to signal 11 (SIGSEGV).

The code I am using is as follows:
...
NSCharacterSet *quoteCharSet = [NSCharacterSet characterSetWithCharactersInString:@"\""]; NSMutableCharacterSet *alphaNumericAndAsteriskSet = [NSMutableCharacterSet alphanumericCharacterSet];
        [alphaNumericAndAsteriskSet addCharactersInString:@"*"];
...
searchWords = [searchWords stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; //discard extraneous characters from nssearchfield
        
searchTermsScanner = [[NSScanner alloc] initWithString:searchWords]; // init the scanner with the search words
        
        while ( ! [searchTermsScanner isAtEnd])
        {
[searchTermsScanner scanUpToCharactersFromSet:quoteCharSet intoString:&foundStrings]; // scan up to a quote [firstScanArray addObject:foundStrings]; //add the quote charcter to the array
                
                if ( ! [searchTermsScanner isAtEnd])
                {
[searchTermsScanner scanUpToCharactersFromSet:alphaNumericAndAsteriskSet intoString:&foundStrings];
                        [firstScanArray addObject:foundStrings];
                }
        }
        NSLog(@"%@", [firstScanArray description]);
...     
        [searchTermsScanner release];
        [pool release];
        
        return 0;
        
}

Can anyone suggest where I am going wrong?

Thanks in advance,
Jason Wiggins

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to