我有这样一份定购单:
aaa
bbb
ccc
ddd
eee
我想核实档案中是否存在“dd”扼杀。
Here my func:
- (BOOL) asd:(NSString*)sting
{
NSArray *LinesCount =
[[NSString stringWithContentsOfFile:@"longfile.txt"
encoding:NSStringEncodingConversionAllowLossy error:nil]
componentsSeparatedByString:@"
"];
unsigned index = (unsigned)CFArrayBSearchValues(
(CFArrayRef)LinesCount,
CFRangeMake(0, CFArrayGetCount((CFArrayRef)LinesCount)),
(CFStringRef)string,
(CFComparatorFunction)CFStringCompare,
NULL);
if (index < [LinesCount count]) return YES;
return NO;
}
为什么它总是以任何扼杀方式返回?