原文链接:http://blog.csdn.net/iotjin/article/details/50384598
//取出字符串中的数字
第一种:
字符串:urlString
NSScanner*scanner = [NSScannerscannerWithString:urlString];
[scannerscanUpToCharactersFromSet:[NSCharacterSetdecimalDigitCharacterSet]intoString:nil];
intnumber;
[scannerscanInt:&number];
NSString*num=[NSStringstringWithFormat:@"%d",number];
第二种:
字符串:urlString
NSCharacterSet* nonDigits =[[NSCharacterSetdecimalDigitCharacterSet]invertedSet];
intremainSecond =[[urlStringstringByTrimmingCharactersInSet:nonDigits]intValue];
NSLog(@" num %d ",remainSecond);