最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】propertyListFromData _:mutabilityOption:format:errorDescription was deprecated in iOS 8.0 Use propertyListWithData:options:format:error instead

Swift crifan 944浏览 0评论
        let str = (String)(NSPropertyListSerialization.propertyListFromData(tempData, mutabilityOption:NSPropertyListMutabilityOptions.Immutable, format:nil, errorDescription: nil))
        

警告:

swift 522:56: ‘propertyListFromData(_:mutabilityOption:format:errorDescription:)’ was deprecated in iOS 8.0: Use propertyListWithData:options:format:error: instead.

如图:

NSPropertyListSerialization Class Reference

最后改为:

//        let str = (String)(NSPropertyListSerialization.propertyListFromData(tempData, mutabilityOption:NSPropertyListMutabilityOptions.Immutable, format:nil, errorDescription: nil))
        var str = ""
        do {
            let properListObj = try NSPropertyListSerialization.propertyListWithData(tempData,
                options:NSPropertyListReadOptions.Immutable,
                format:nil)
            if properListObj is String {
                str = properListObj as! String
            }
        }catch let error as NSError {
            print("error=\(error.localizedDescription)")
        }
       
        return str

即可。

转载请注明:在路上 » 【已解决】propertyListFromData _:mutabilityOption:format:errorDescription was deprecated in iOS 8.0 Use propertyListWithData:options:format:error instead

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
60 queries in 0.090 seconds, using 18.61MB memory