以下示例程序輸出相同,但程序無法正常工作。IOS isEqualToString不工作
NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager defaultManager]
enumeratorAtPath:kDocdir];
for (NSString *pathi in directoryEnumerator)
{
NSString *fileName_Manager = [pathi lastPathComponent];
NSLog(@"fileName_Manager = %@",fileName_Manager);
Artist *name_Databse = [self.fetchedResultsController
objectAtIndexPath:IndexPath];
NSLog(@"name_Databse = %@",name_Databse.name);
if ([fileName_Manager isEqualToString:name_Databse.name]) {
NSLog(@"Same Name");
}else{
NSLog(@"Different Name");
}
}
輸出:
2013-04-25 15:37:43.256 Player[36436:907] fileName_Manager = alizée - mèxico - final j'en
2013-04-25 15:37:43.272 Player[36436:907] name_Databse = alizée - mèxico - final j'en
2013-04-25 15:37:44.107 Player[36436:907] Different Name
不名正常工作時的特殊字符。這是爲什麼發生? 謝謝...
這裏有同樣的問題:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@",[pathi lastPathComponent]];
如何進行編輯在這裏?
試試只是isEqual: – Eric 2013-04-25 13:04:47
你可能在你的字符串中有空格,嘗試刪除多餘的空格或換行符 – nsgulliver 2013-04-25 13:04:58
請考慮我對答覆的高度優先答案! – GoZoner 2013-08-22 23:03:39