I need to create a reference application that will contain various articles that should be stored in the application itself, and not on the server or site.

How do I store the texts of these articles in the app?

    3 answers 3

    Using CoreData - the best way, a lesson for Swift

    You can also store recipes in a plist file, a lesson for Swift.

    • one
      Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky

    CoreData can be used, but I think it is not justified difficult for the directory application.

    The choice of instrument depends on many factors - what technologies you know how you know, in what format the data is stored, it is just text or text with some formatting markers, etc.

    Look towards using TextKit. Simple tutorial

    If you are interested, you can google / buy an advanced lesson from raywenderlich, there was an example - an application reader, there is a text file with formatting markers, it is read block by block and is beautifully displayed on the screen.

    Update:

    A couple of ways to save data in the application:

    • If the logic allows, you can save to file
    • Use NSKeyedArchiver, NSKeyedUnarchiver save on exit and load on entry Tutorial
    • NSUserDefaults, I think not quite suitable for you
    • CoreData / Realm
    • Something custom, you can try Parse.com Local Datastore
    • I am interested in the very method of storing texts in the application. It is clear that I can not store them simply by strings in the code. And where should I keep these texts? - yuraist
    • @yuraist corrected the answer - Tikhonov Alexander

    Text information in the application is most conveniently stored in plist. In the Project Navigator, right-click and select NewFile -> Resourse -> Property List. In this plist copy-paste text in the form that is needed for the tasks of the application (individual sentences, paragraphs, pages, chapters, or an entire book). Plist allows you to refer to each section by points (item). How to use a plist is not obvious, but there are many simple lessons.