NSFileManager creating folder (Cocoa error 513.)

前端 未结 4 1163
深忆病人
深忆病人 2020-12-02 17:33

I\'m trying to create a folder inside the /sounds folder of my app.

-(void)productPurchased:(UAProduct*) product {
    NSLog(@\"[StoreFrontDelegate] Purchase         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 17:57

    I'm still not totally clear on the meaning of the 513 error in my case, but I was getting it when just trying to read an opened file URL using [NSFileHandle fileHandleForReadingFromURL:theUrl error:&err ].

    I realized from this answer that with iOS 13, I now need to use startAccessingSecurityScopedResource to access external files that are opened in the app. When I wrapped my file calls as follows, then the error 513 stopped occurring:

    if( [myURL startAccessingSecurityScopedResource] ) 
    {
        NSFileHandle* myFile = [NSFileHandle fileHandleForReadingFromURL:myURL error:&err ];
        // ...Do file reads here...
        [theUrl stopAccessingSecurityScopedResource];
    }
    

提交回复
热议问题