1
下面的示例程序:儘管相同的url它找不到url,但程序無法正常工作。IOS NSPredicate不能正常工作
NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:kDocdir];
for (NSString *pathi in directoryEnumerator)
{
NSLog(@"fileManager_url = %@",[self Doc_Del:pathi]);
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"url == %@",[self Doc_Del:pathi]];
[fetchRequest setPredicate:predicate];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:nil];
Artist *url_Databse = [self.fetchedResultsController objectAtIndexPath:self.indexPath_k];
NSLog(@"Database_url = %@",url_Databse.url);
if ([fetchedObjects count] > 0) {
NSLog(@"foundurl = %@",((Artist *)[fetchedObjects objectAtIndex:0]).url);
}else{
NSLog(@"url not found");
}
}
輸出:
2013-04-25 15:37:43.256 Player[36436:907] fileManager_url = /alizée -öş mèxico - final j'en
2013-04-25 15:37:43.272 Player[36436:907] Database_url = /alizée -öş mèxico - final j'en
2013-04-25 15:37:44.107 Player[36436:907] url not found
不URL正常工作時的特殊字符。這是爲什麼發生?謝謝...
你有沒有嘗試把單引號內的特殊字符?所以你的謂詞是@「url ='%@'」。 – JDx 2013-04-26 11:02:07
是的,我嘗試過。不這樣工作 – user2041226 2013-04-26 11:05:03