如何从NSArray中删除.DS_Store?

时间:2014-04-01 06:57:25

标签: objective-c nsfilemanager

我有一个代码可以将对象移出路径@“/ Users / playra / Desktop / 2 DivyaLoka /СобраниеТайн”

- (void) setPathProperty:(NSString *)pathProperty
{
    _pathProperty = pathProperty;
    NSArray* allContents = [[NSFileManager defaultManager]  contentsOfDirectoryAtPath:pathProperty error:nil];
    self.contents = allContents;
    [self.tableView reloadData];
    self.navigationItem.title = [self.pathProperty lastPathComponent];
}

这一行下面是对象.DS_Store

NSArray* allContents = [[NSFileManager defaultManager]  contentsOfDirectoryAtPath:pathProperty error:nil];

如何从那里删除它?

1 个答案:

答案 0 :(得分:1)

试试这个:

NSMutableArray * dirContents = [[NSMutableArray alloc] initWithArray:docDir];
if([docDir containsObject:@".DS_Store"])
{
    [dirContents removeObject:@".DS_Store"];
}