应该为true时,我的fileExistsAtPath语句返回false

时间:2016-08-14 13:29:54

标签: ios swift nsfilemanager file-exists

我使用以下代码检索用户设备上的收据:

let receiptUrl = NSBundle.mainBundle().appStoreReceiptURL

然后我使用以下方法检查receiptURL的值:

print("receiptUrl is \(receiptUrl)")

我的控制台将位置显示为:

receiptUrl is Optional(file:///private/var/mobile/Containers/Data/Application/018CF51F-1F55-465B-AA98-B4AD5A864E06/StoreKit/sandboxReceipt)

然后我使用if语句:

if NSFileManager.defaultManager().fileExistsAtPath(receiptUrl!.path!)
    { //do great security stuff
    }

但是,我的fileExistsAtPath始终返回false。非常令人沮丧。

1 个答案:

答案 0 :(得分:0)

这是正确的结果。 appStoreReceiptURL不显示存在的路径。只显示商店收据文件夹将在那里。此答案与this

相关
相关问题