Hi Choo
I had to use standardUserDefaults instead:-
func loadMenuSettings()
{
pListDictionary = loadPlistFile("datalist.plist")
print(pListDictionary.description)
tickHelp = pListDictionary.objectForKey("help") as! Bool
tickMute = pListDictionary.objectForKey("mute") as! Bool
tickMusic = pListDictionary.objectForKey("music") as! Bool
hiScore = pListDictionary.objectForKey("hiscore") as! Int
firstEntry = pListDictionary.objectForKey("firstentry") as! Bool
helpcount = pListDictionary.objectForKey("helpcount") as! Int
#if os(tvOS)
if let isValid = NSUserDefaults.standardUserDefaults().objectForKey("help")
{
tickHelp = NSUserDefaults.standardUserDefaults().objectForKey("help") as! Bool
tickMute = NSUserDefaults.standardUserDefaults().objectForKey("mute") as! Bool
tickMusic = NSUserDefaults.standardUserDefaults().objectForKey("music") as! Bool
hiScore = NSUserDefaults.standardUserDefaults().objectForKey("hiscore") as! Int
firstEntry = NSUserDefaults.standardUserDefaults().objectForKey("firstentry") as! Bool
helpcount = NSUserDefaults.standardUserDefaults().objectForKey("helpcount") as! Int
print("user defaults iOSTV",(NSUserDefaults.standardUserDefaults().description))
}
else
{
NSUserDefaults.standardUserDefaults().setBool(tickHelp, forKey: "help")
NSUserDefaults.standardUserDefaults().setBool(tickMute, forKey: "mute")
NSUserDefaults.standardUserDefaults().setBool(tickMusic, forKey: "music")
NSUserDefaults.standardUserDefaults().setBool(firstEntry, forKey: "firstentry")
NSUserDefaults.standardUserDefaults().setInteger(hiScore, forKey: "hiscore")
NSUserDefaults.standardUserDefaults().setInteger(helpcount, forKey: "helpcount")
NSUserDefaults.standardUserDefaults().synchronize()
print("Setting up user defaults for iOSTV")
}
to save
#if os(tvOS)
if let isValid = NSUserDefaults.standardUserDefaults().objectForKey("help")
{
NSUserDefaults.standardUserDefaults().setBool(tickHelp, forKey: "help")
NSUserDefaults.standardUserDefaults().setBool(tickMute, forKey: "mute")
NSUserDefaults.standardUserDefaults().setBool(tickMusic, forKey: "music")
NSUserDefaults.standardUserDefaults().setBool(firstEntry, forKey: "firstentry")
NSUserDefaults.standardUserDefaults().setInteger(hiScore, forKey: "hiscore")
NSUserDefaults.standardUserDefaults().setInteger(helpcount, forKey: "helpcount")
NSUserDefaults.standardUserDefaults().synchronize()
print("Saving user defaults for iOSTV")
}
#else
/
pListDictionary["help"] = tickHelp
pListDictionary["music"] = tickMusic
pListDictionary["mute"] = tickMute
pListDictionary["firstentry"] = firstEntry
pListDictionary["hiscore"] = hiScore
pListDictionary["helpcount"] = helpcount
/
pListDictionary.writeToFile(pathToSave, atomically: false)
print(pListDictionary.description)
/
#endif