iOS7到iOS8应用程序文件的迁移 [英] iOS7 to iOS8 application files migration
问题描述
应用程序文件系统结构在iOS8上发生了变化(请阅读 iOS 4 beta版本说明和文件系统编程指南)。
当iOS8将安装在设备上时,我想所有先前安装的应用程序和所有相关文件(在文档,应用程序支持等)将被重新组织以匹配新的结构。
你们是否有任何关于在iOS7到iOS8升级期间发生的变化列表的线索?我找不到有关此主题的任何文档。
有没有一种方法来测试/模拟将iOS7应用程序沙箱迁移到新的iOS8沙箱结构?
谢谢
BONUS问题:操作系统升级时应用程序的GUID是否改变?
应用程序容器的文件系统布局在磁盘上已更改。
而不是依靠硬编码的目录结构,使用
NSSearchPathForDirectoriesInDomains
函数或
URLForDirectory:inDomain:appropriateForURL:create:error:
方法
NSFileManager
使用URLForDirectory:inDomain:appropriateForURL:create:error:
方法NSFileManager
:
$ bNSFileManager * yourFileManager = [NSFileManager defaultManager];
NSURL * urlForSomeDirectory = [yourFileManager URLForDirectory:NSDocumentDirectory inDomain:NSAllDomainsMask appropriateForURL:nil create:YES error:nil];
如果您正在使用此方法,那么您不需要你可以用 NSDocumentDirectory 。 其他常量 。你可能还想用
NSError **
来代替最后一个参数。
奖金问题:它不应该,但是你永远不知道。
I am currently testing my app on iOS8. Everything works well on pure iOS8 but I am struggling with the App files migration from iOS7 that will occur for users when iOS8 will be publicly released. As my application uses several "Standard Directories" (Documents, Application Support, ...), I would like to be sure the migration will be smooth.
The application filesystem structure has changed on iOS8 (read iOS beta 4 Release note and the file system programming guide).
When iOS8 will be installed on a device, I guess all previously installed applications and all related files (in Documents, Application Support, ...) will be re-organized to match the new structure.
Do you guys have any clues about the (exhaustive) list of changes that will occur during iOS7 to iOS8 upgrade ? I can't find any documentation on this subject. Is there a way to test/simulate a migration of an iOS7 application sandbox to the new iOS8 sandbox structure ?
Thanks
BONUS question: does the application GUID change when the OS upgrades ?
解决方案The file system layout of app containers has changed on disk.
Rather than relying on hard-coded directory structure, use the
NSSearchPathForDirectoriesInDomains
function or theURLForDirectory:inDomain:appropriateForURL:create:error:
method of theNSFileManager
class.Using the
URLForDirectory:inDomain:appropriateForURL:create:error:
method ofNSFileManager
:NSFileManager *yourFileManager = [NSFileManager defaultManager]; NSURL *urlForSomeDirectory = [yourFileManager URLForDirectory:NSDocumentDirectory inDomain:NSAllDomainsMask appropriateForURL:nil create:YES error:nil];
If you are currently using this method, then you don't need to change a thing.
You can replace
NSDocumentDirectory
with many other constants. You may also want to substitute aNSError **
for the last parameter if you would like to catch an error.The bonus question: It shouldn't, however you never know.
这篇关于iOS7到iOS8应用程序文件的迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!