File search with specific Extension Objective c

后端 未结 6 1483
我在风中等你
我在风中等你 2020-12-11 07:36

I am working on some file manipulation in iPhone project. Where i need to search files of specific extension. One option is to manually process each file & directory to

6条回答
  •  一生所求
    2020-12-11 08:16

    Yes we have direct method for NSArray below helps you

     NSMutableArray *arrayFiles = [[NSMutableArray alloc] initWithObjects:@"a.png", @"a.jpg",  @"a.pdf", @"h.png", @"f.png", nil];
        NSLog(@"pathsMatchingExtensions----%@",[arrayFiles pathsMatchingExtensions:[NSArray arrayWithObjects:@"png", nil]]);
    
    //my output is
    "a.png",
    "h.png",
    "f.png"
    

提交回复
热议问题