How to use NSScanner?

Posted by Zopi on Stack Overflow See other posts from Stack Overflow or by Zopi
Published on 2009-02-27T13:42:04Z Indexed on 2010/05/10 2:18 UTC
Read the original article Hit count: 211

Hi,

I've just read Apple's docu of NSScanner. I'm trying to get the integer of that string: @"user logged (3 attempts)".

I can't find any example, how to scan within parentheses. Any ideas?

Here's the code:

NSString *logString = @"user logged (3 attempts)";
NSScanner *aScanner = [NSScanner scannerWithString:logString];

[aScanner scanInteger:anInteger];

NSLog(@"Attempts: %i", anInteger);

Regrads,

Ruby

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about string