7

Trying to use the code block below, but don't know how to get the options bit to work in the else clause, I keep getting 'NSPropertyListMutabilityOptions' is not convertible to 'NSPropertyListReadOptions'. But the Read options don't have MutableContainersWithLeaves that I need.

//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)
    }

1 Answers1

11

The options parameter has the type NSPropertyListReadOptions which is a type alias for Int.

NSPropertyListMutabilityOptions is a RawOptionSetType with Uint as the underlying raw type.

Therefore you have to convert the option to an Int with

appStats = NSPropertyListSerialization.propertyListWithData(appStatsData,
    options:Int(NSPropertyListMutabilityOptions.MutableContainersAndLeaves.rawValue),
    format: nil, error: &error)
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382