如何获取IOS8模拟器的Documents路径地址
文章目录
原文见这里
Xcode5中模拟器的Documents路径地址是:Library/Application Support/iPhone Simulator/7.1/Applications/cryptic number/
Xcode6中路径为:Library/Developer/CoreSimulator/Devices/cryptic number/data/Containers/Data/Application/cryptic number
其中cryptic number是一段编码后的字符串,在Xcode5的路径中只有一个,可以很容易猜出来,而在Xcode6中有两个,就不容以猜出来了。
在Xcode6中可以通过在applicationDidFinishLaunching方法中加入下面的代码在每次程序启动时都输出模拟器的Documents路径。
#if TARGET_IPHONE_SIMULATOR
// where are you?
NSLog(@"Documents Directory: %@", [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
#endif
但是每次重新启动程序,该路径都会发生变化,因为cryptic number会发生变化。如果如果重启程序时你的Finder程序已经打开了上次的Documents路径,即使路径发生变化,Finder也会更新到新的路径。
另一个找到模拟器Documents路径的方法是通过下面的命令搜索:sudo find /Library/Developer/CoreSimulator/Devices -name ‘WhereAreYou*’
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论