【发布时间】:2015-11-13 06:45:46
【问题描述】:
我使用以下代码从 JSON 文件中检索数据。
let jsonData = try NSData.dataWithContentsOfMappedFile("/Users/User/Desktop/Employee.json")
我收到以下错误
dataWithContentsOfMappedFile was deprecated in iOS 8.0: Use +dataWithContentsOfURL:options:error: and NSDataReadingMappedIfSafe or NSDataReadingMappedAlways instead
有人可以告诉我替代方案吗?
【问题讨论】:
-
您也没有建议的解决方案吗?
Use +dataWithContentsOfURL:options:error: and NSDataReadingMappedIfSafe or NSDataReadingMappedAlways instead你试过了吗? -
@NeverHopeless 我不想从任何网址使用它。文件在我的本地
-
真的,就在头文件里。 所有已弃用的方法在头文件中有一行,告诉您改用什么。