我的字符串是k = / Users / applefan / Library / Application Support / iPhone Simulator / 3.1.3 / Applications / 422B3239-F521-4985-89FE-EC778C57C0AB / Documents / 1.sql < / p>
现在如何从1.sql
获取 1我做了这样的事情
NSScanner *scanner = [NSScanner scannerWithString:storePath];
[scanner scanUpToString:@".sql" intoString:&k] ;
NSLog(@"test is %@",k);
我也这样做了
unsigned int intValue;
while([scanner isAtEnd] == NO) {
[scanner scanHexInt:&intValue];
NSLog(@"HEX : %d", intValue);
**}
它给了我所有的int值**
但我只想要 / Documents /
之后的数值答案 0 :(得分:2)
NSString *k = @"/Users/applefan/Library/Application Support/iPhone Simulator/3.1.3/Applications/422B3239-F521-4985-89FE-EC778C57C0AB/Documents/1.sql";
NSString *one = [[[[k componentsSeparatedByString:@"Documents/"] objectAtIndex:1]
componentsSeparatedByString:@".sql"] objectAtIndex:0];
NSLog(@"Is it one? %@", one);