如何在Swift 3中显示文件共享中的文件 [英] how to Display Files From Files Sharing in Swift 3

查看:71
本文介绍了如何在Swift 3中显示文件共享中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序的Plist中添加了文件共享,因此,当iPhone与iTunes连接到我的mac时,我可以轻松地复制文件,但是问题是,当我在我的应用程序中使用iTunes复制一些文件并运行该应用程序时,我有2问题:

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-当我停止应用程序并再次打开该应用程序时,我在文件共享部分看不到iTunes中的任何文件

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

2-此下面的代码应该在有文件的情况下打印文件存在,在没有文件但仅存在文件的情况下打印其他内容

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

这是我的代码

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

推荐答案

为iOS应用程序启用文件共享时,它允许您的用户复制,删除和重命名应用程序的文档"文件夹中的文件,以及在应用程序的文档"文件夹中

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.

您的代码需要首先获得对其自己的Documents文件夹的引用(该文件夹可在您的应用每次运行时更改).

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

然后,它可以使用 FileManager 的各种方法从该文件夹中获取文件列表.

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

这篇关于如何在Swift 3中显示文件共享中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆