I've a mutable dictionary (in form of [Int:Int]) and want that to save it. I would use NSUserDefaults like that:
var myDic: NSMutableDictionary = [:]
myDic = [1:2]
NSUserDefaults.standardUserDefaults().setObject(myDic, forKey: "myDic")
Thread 1: signal SIGABRT
setObject(_:forKey:) can’t accept
Dictionary with a key which is integer type. The method requires property-list objects, but
myDic = [1:2] is not property-list object.
There are two documents about it.
valueparameter can be only property list objects:
NSDictionaryobjects, their contents must be property list objects.
CFDictionaryobjects allow their keys to be objects of any type, if the keys are not string objects, the collections are not property-list objects.
If you set a integer-key to
Dictionary object cannot be used for a value of
setObject. You have to use a string for the key like this:
myDic = ["1": 2]