NSUserDefaults Not Saving TextField Text (Swift)

前端 未结 5 2035
天涯浪人
天涯浪人 2021-01-01 05:52

I\'m trying to create a game with Swift, and I want to add the ability to create a username, which will be saved in NSUserDefaults. This is my code:

println(&         


        
5条回答
  •  别那么骄傲
    2021-01-01 06:25

    For swift 3.0, You can create user default by,

    UserDefaults.standard.set("yourValue", forKey: "YourString")
    

    To Print the value in console :

    print(UserDefaults.standard.string(forKey: "YourString")!)
    

提交回复
热议问题