1

私の文字列は 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/の後の数値のみが必要です

4

1 に答える 1

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);
于 2011-01-28T10:23:37.560 に答える