Saving Array to Plist file that contains Custom Objects iPhone

前端 未结 5 1296
猫巷女王i
猫巷女王i 2021-02-04 22:39

I have a class called XYZ inheriting from NSObject and an array which contains objects of XYZ. I need to write this array to a plist file on to documents directory. After trying

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 23:22

    You need to implement two methods: -initWithCoder: and -encodeWithCoder:. Read the NSCoding docs; they’re pretty straight-forward methods. You basically want to encode/decode your instance variables with a key that corresponds to its name.

提交回复
热议问题