从 FileManager 获取 app Group 的路径 [英] Obtain the path of app Group from FileManager

查看:40
本文介绍了从 FileManager 获取 app Group 的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 WatchKit 更新我的应用程序,并且我通常将 NSKeyedArchiver 文件保存到 NSDocumentsDirectory.更新到应用程序组后,我需要将其存储在应用程序组文件夹中.我遇到的问题是我无法弄清楚如何获取路径,而不是将其作为我正在寻找的文件引用.

I am trying to update my app for WatchKit and I save a NSKeyedArchiver file to the NSDocumentsDirectory normally. With updating to app groups I need to store it in the app groups folder. The issue I am having is I cant figure out how to just get the path, and not have it referenced as a file I am looking for.

现在设置的方式是找到它给出的路径作为 NSString 的文件

The way it is set up now is to find the file it gives the path as a NSString

/Users/ME/Library/Developer/CoreSimulator/Devices/43F/data/Containers/Data/Application/5E/Documents/fav

但是当我存储到应用程序组时,无论我通过哪种方式访问​​该文件夹,它都会返回

but when I store to app groups, no matter which way I access the folder, it is returned

file:///Users/ME/Library/Developer/CoreSimulator/Devices/43F/data/Containers/Data/Application/5E/Documents/fav

获取共享组路径而不是让应用查找直接文件的最佳方法是什么?

What is the best way to just obtain the path to the shared group, rather than have the app looking for the direct file?

推荐答案

咖啡让我忘记了文件管理器的 .path.

So coffee deprived me had forgotten about the .path for filemanager.

NSURL *fileManagerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.com"];
NSString *tmpPath = [NSString stringWithFormat:@"%@", fileManagerURL.path];
NSString *finalPath = [NSString stringWithFormat:@"%@",[string stringByAppendingString:@"/Favourites2"]];

这篇关于从 FileManager 获取 app Group 的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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