Objective C Data Caching on iOS

前端 未结 6 1656
北海茫月
北海茫月 2021-02-01 21:30

I am pulling data from an API and then building out my data objects with it. I want to cache this data for the future. I have been storing the string from the api in NSUserDef

6条回答
  •  花落未央
    2021-02-01 21:47

    There are many different solutions to this problem and there is no "right" way to do it. A few popular options are:

    • Core Data - Apple's framework for persistence. Very performant, but more difficult.
    • SQLite - Fast and flexible, but bare bones.
    • Plists - Basically writing a file to disk, you have to read and write manually.
    • NSUserDefaults - The lightest weight "key-value" option.

    I would encourage you to read up on all four and see which one works best for you.

提交回复
热议问题