加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在swift中使用NSPropertyListSerialization.propertyListWithDat

发布时间:2020-12-14 05:26:05 所属栏目:百科 来源:网络整理
导读:试图使用下面的代码块,但不知道如何让选项位在else子句中工作,我不断得到’NSPropertyListMutabilityOptions’不能转换为’NSPropertyListReadOptions’.但Read选项没有我需要的MutableContainersWithLeaves. //if the file does not already exist if(appSt
试图使用下面的代码块,但不知道如何让选项位在else子句中工作,我不断得到’NSPropertyListMutabilityOptions’不能转换为’NSPropertyListReadOptions’.但Read选项没有我需要的MutableContainersWithLeaves.
//if the file does not already exist
    if(appStatsData != nil) {
        appStats.setObject(NSNumber.numberWithInt(0),forKey:"RunCount")
        appStats.setObject("No Courses Viewed",forKey:"LastCourseViewed")
    }else {
        appStats = NSPropertyListSerialization.propertyListWithData(appStatsData,options:     NSPropertyListMutabilityOptions.MutableContainersAndLeaves,format: nil,error: &error)
    }
options参数的类型为NSPropertyListReadOptions,它是一种类型别名
对于Int.

NSPropertyListMutabilityOptions是一个RawOptionSetType,其中Uint作为底层
原始类型.

因此,您必须将选项转换为Int with

appStats = NSPropertyListSerialization.propertyListWithData(appStatsData,options:Int(NSPropertyListMutabilityOptions.MutableContainersAndLeaves.rawValue),error: &error)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读