Using NSPropertyListSerialization.propertyListWithData in fast

Trying to use the code block below, but don’t know how to get the parameters bit to work in the else clause, I keep getting "NSPropertyListMutabilityOptions", which does not convert to "NSPropertyListReadOptions". But the Read parameters do not have the 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) } 
+7
ios8 swift xcode6
source share
1 answer

The options parameter is of type NSPropertyListReadOptions , which is a type alias for Int .

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

So you need to convert the option to Int with

 appStats = NSPropertyListSerialization.propertyListWithData(appStatsData, options:Int(NSPropertyListMutabilityOptions.MutableContainersAndLeaves.rawValue), format: nil, error: &error) 
+11
source share

All Articles