如何获取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*’

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值