Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于iphone的一个简单问题_Iphone_Nsscanner - Fatal编程技术网

关于iphone的一个简单问题

关于iphone的一个简单问题,iphone,nsscanner,Iphone,Nsscanner,我的字符串是k=/Users/applefan/Library/Application Support/iPhone Simulator/3.1.3/Applications/422B3239-F521-4985-89FE-EC778C57C0AB/Documents/1.sql 现在,如何从1.sql获取1 我做过这样的事 NSScanner *scanner = [NSScanner scannerWithString:storePath]; [sca

我的字符串是k=/Users/applefan/Library/Application Support/iPhone Simulator/3.1.3/Applications/422B3239-F521-4985-89FE-EC778C57C0AB/Documents/1.sql

现在,如何从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/

之后的数值,我们需要更多关于您的具体情况的信息。如果每次字符串的格式都完全相同,则只需执行
[NSString stringByRemovingOcurrencesOfString:withString:]如果比这稍微复杂一点,我们可以研究其他选项。我只需要Documents/后面的数字值,不管值是什么
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);