iPhone:文件夹管理

发布于 2024-09-10 15:06:52 字数 184 浏览 0 评论 0原文

我在任何地方都没有找到这个问题的答案,但这似乎是一个典型的问题: 我的“资源”文件夹中有一个 XML 文件,我的应用程序需要它来显示一些信息。但我必须检查我的服务器,看看该服务器是否有更新的 XML 可用,所以我应该将我的 XML(在资源文件夹中)替换为这个新的 XML。

我怎样才能做到这一点?

预先感谢您的任何帮助!

I've not found a answer to this question anywhere, but this seems like a typical problem:
I have in my "Resources" Folder a XML File that my App needs to show some informations. But I have to check in my Server, if the server has a newer XML available, so I should replace my XML (in the resources folder) for this new one.

How can I achieve that?

Thanks in advance for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

坏尐絯 2024-09-17 15:06:52

我不确定您是否具有对资源部分的写入权限。更好的方法是将文件夹下载到“文档”目录中。然后,当您的应用程序检查加载 XML 文件时,它应该查看文档目录中是否有版本并首先加载该版本。如果找不到替代版本,则会使用原始版本。

这意味着如果下载的 XML 文件存在问题,则可以使用原始 XML 文件。发生这种情况时,要么是网络被切断而没有完成,要么是服务器提供了错误的 xml 文件并且无法验证。

您可以使用以下方式访问文档目录:

NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
NSString *destinationpath = [docPaths lastObject];

如果您想要检查版本,可以使用 XML 内的元素来提供版本号,也可以使用上次修改日期。版本的示例可以是:

<myxml version="234">

然后您可以检查该值。

I'm not sure you get write access to the Resources section. A better way to do it, is to download the folder to your "Documents" directory. Then when you app checks to load the XML file, it should see if there is a version in the documents directory and load that first. If it doesn't find a replacement one, then it uses the original version.

This means the original XML file can be used if there is some issue with the downloaded one. Which happens, either the network got cutoff and didn't finish, or the server gave the wrong xml file and it doesn't validate.

You can access the document directory using:

NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
NSString *destinationpath = [docPaths lastObject];

If you are wanting to check the versions, you can use an element inside the XML to give you the version number or you can use the Last-Modified date. An example of the version could be:

<myxml version="234">

Then you could check this value.

听不够的曲调 2024-09-17 15:06:52

您可以让 API 方法检查最近的修改日期。在客户端站点中,您可以获取 XML 文件的最近修改日期,并与服务器中的日期进行比较。您可以获取 XML 文件的描述并返回 true 或 false 进行替换。

You can let the API, a method to check The most recent modified date. And in the client site, you can get your most recent modified date of the XML file and compare with the one in the server. You can get the description of the XML file and return true or false to replace.

一向肩并 2024-09-17 15:06:52

您需要某种方法来区分新 XML 和旧 XML。我假设你有某种机制可以做到这一点。通常是 XML 内的某种版本节点。
如果服务器的版本和你手机上的版本不同,请获取新版本,否则不执行任何操作。

U need some way to distinguish the new XML from the old one. I assume you have some mechanism to do that. Typically some kind of Version node inside the XML.
If the server's version and the one on ur phone is different, get the new one else don't do anything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文