how to Display Files From Files Sharing in Swift 3

2019-07-11 11:54发布

问题:

A added File Sharing in Plist in My app So I can Easily Copy Files when The iPhone has connect with iTunes to my mac But the problem is that when I copy some files with iTunes in my App and Run the app I have 2 Problems :

1- when I stop the app and open that again I can't see any files in iTunes in the file sharing part

2- This code Below here should print file Exists if there is file and print some thing else if there isn't file But Just Print File Exists

here is my codes

if filemgr.fileExists(atPath: "/Applications") {
            print("File exists")
        } else {
            print("File not found")
        }

when I click the button to check files I just See File Exists even when I delete the app and install it again please help me

回答1:

When you enable file sharing for an iOS app, it allows your users to copy, delete, and rename files that to, from, and in your app's Documents folder.

Your code needs to first get a reference to its own Documents folder (which can change each time your app runs).

Then it can use the various methods of FileManager to get a list of files from that folder.