NSUserDefaults standardUserDefaults not working in iOS8

NSUserDefaults doesn't seem to work for me in iOS8. When I run simple code, it crashes with this error and points to a line with setDouble :

Subject 1: EXC_BAD_ACCESS (code = 1, address = 0xffffffffc)

code:

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { let defs = NSUserDefaults.standardUserDefaults() defs.setDouble(2.5, forKey: "foo") return true } 

What am I doing wrong?

+6
source share
1 answer

I had the same error when I first upgraded to beta 3, but solved it by clearing my project.

Try "Product - Clear"

Worked for me, although he had no idea what the real problem was.

0
source

Source: https://habr.com/ru/post/971978/


All Articles