Converting custom class object into NSData

后端 未结 3 865
清歌不尽
清歌不尽 2021-02-01 03:20

I have a custom class that I want to save into NSUserDefaults. I am told that I need to convert the class object into data in order to save it to NSUserDefaul

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 04:07

    This link can help you

    It is important your class extend NSObject and NSCoding, because the convert need be its class, NSCoding is an interface to serialize and deserialize your class

    Saving custom SWIFT class with NSCoding to UserDefaults

提交回复
热议问题