简体   繁体   中英

How to store immutable text in iOS app (to be available at first and every launch)?

I am new to iOS Programming, and have very little experience in programming in general (high school level only). Recently signed up for an iOS Developer account and want to create a Movie Quotes app.

I want to employ Core Data to save more than 300,000 quotes which will have these entities. The text file's size is around 8 MB.

Quotes : Att: theQuote Rel: saidByCharacter, fromMovie

Movies : Att: movieName, moviePosterLink Rel: quotesFromThisMovie (to-many), characters (to-many)

MovieCharacter : Att: characterName Rel: fromMovie

Obviously all this data has to be included within the app. Also there will be a folder containing more than 50,000 small images for the movie posters.

My question is how can I store textual info inside the app (using Core Data)?

I have read Apple's Core Data Tutorial for iOS, Core Data Programming Guide, watched Stanford's iOS course, read Stephen Kochan's book on Objective-C, and searched on the Internet for some info regarding this really introductory task, but have found nothing. Am wondering if this thing is so ridiculously easy that it doesn't need a tutorial...

看看Ray Wenderlich的核心数据教程 -特别是第2部分 ,它是关于如何将种子数据添加到您的应用程序的。

Should you choose to go with Core Data--

Ray Wenderlich's tutorial is pretty good:

http://www.raywenderlich.com/934/core-data-on-ios-5-tutorial-getting-started

However, working with Core Data directly requires a LOT of boiler plate code, which is kind of a pain. To address this, Magical Record (and helper classes Magical Import) was created, and it really simplifies the process:

https://github.com/magicalpanda/MagicalRecord

However, as Wenderlich's second tutorial on "Preloading Data" talks about, you're going to need some way to get the data into Core Data first.

To do this, you can use a flat file (such as sqlite/sqlite3 file) within the app's bundle, or you can setup a web service (for content that changes over time, controlled by you, which isn't possible if you bundle it into the app).

You can also find a tutorial on creating a web service drive app on Wenderlich's site, too.

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM