iPhone SDK Xcode - How to get all the filenames in the documents dir

前端 未结 1 1302
陌清茗
陌清茗 2021-02-09 05:19

I want to get all the filenames in my application\'s documents folder, and place them in an NSMutableArray. Nothing more, nothing less.

1条回答
  •  情深已故
    2021-02-09 05:47

    There is a convenient method in NSFileManager:

    NSFileManager *fileManager = [[NSFileManager alloc] init];
    NSArray *files = [fileManager contentsOfDirectoryAtPath:documentsDirectory 
                                                      error:nil];
    ...
    [fileManager release];
    

    As of ARC you can of course drop the release statement.

    0 讨论(0)
提交回复
热议问题