how to get URL Path for directory inside Document directory?

前端 未结 4 1108
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 10:53

How can I get url path for a particular directory inside Document Directory.

like Document/Art/

My code

- (NSURL *)localRoot {
         


        
4条回答
  •  滥情空心
    2021-01-19 11:19

    Based on above answer here is an simple methode that returns, path for given directory:

    + (NSString *) pathFor : (NSString *) directoryName{
        return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:directoryName];
    }
    

    You need to implement it in ClassName.m and call as:

    NSString *pathForDirectory = [ClassName pathFor:dirName]; //@"Art" in your case
    

提交回复
热议问题