iphone - how to check if the file is a directory , audio , video or image?

后端 未结 5 1291
长发绾君心
长发绾君心 2021-01-31 02:54

Following my program shows contents of Documents directory and is displayed in a tableView . But the Documents directory contains some directories , some audio , some video , an

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 03:40

    Look at the NSURL class. You can for example see if the url is a file url by saying isFileUrl.

    Additionally you can get the last component of the url (usually the file name) by doing:

    NSString *filename = [[url path] lastPathComponent];
    

    These can help you do what you need, but more importantly look at the NSURL documentation.

提交回复
热议问题