我想检查我的document文件夹中的所有目录,并列出名称不在名为eventList的NSArray中的目录。Evenlist是一个ALAssetsGroup数组。代码如下:
NSLog(@"eventList %@",eventList);
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableArray *tagsFolderList = [[NSMutableArray alloc] init];
tagsFolderList = [[fileManager contentsOfDirectoryAtPath:tagsPath error:nil] mutableCopy];
NSLog(@"tagsFolderList %@",tagsFolderList);
if(([tagsFolderList count] > 0) && ([eventList count] > 0))
{
for (int i=0; i<[eventList count]; i++) {
NSString *eventName = [[eventList objectAtIndex:i] valueForProperty:ALAssetsGroupPropertyName];
NSLog(@"eventName %@",eventName);
[tagsFolderList removeObjectIdenticalTo:eventName];
}以下是日志:
eventList (
"ALAssetsGroup - Name:19 ao\U00fbt 2012, Type:Event, Assets count:27",
"ALAssetsGroup - Name:21 ao\U00fbt 2012, Type:Event, Assets count:8",
"ALAssetsGroup - Name:2 nov. 2012, Type:Event, Assets count:12",
"ALAssetsGroup - Name:4 nov. 2012, Type:Event, Assets count:9"
)
tagsFolderList (
"1 nov. 2012",
"19 aou\U0302t 2012",
"2 nov. 2012",
"4 nov. 2012",
"6 oct. 2012"
)
eventName 19 août 2012即使ALAssetsGroup和目录的名称对于ie来说是相同的“2012年11月4日”,我也不能删除对象。我只是尝试了许多字符串编码转换,但没有成功。
有什么建议吗?
问候
发布于 2012-11-08 01:42:48
removeObjectIdenticalTo:比较对象地址,而不是字符串值。因此,即使字符串是相同的字符运行,它们也必须是完全相同的对象。如果您想要比较那些具有相似字符的字符串,请使用NSString的isEqualToString方法。
https://stackoverflow.com/questions/13274419
复制相似问题