1

I am about to read a text file from the app bundle and I have read some of the posts about reading text files such as this: Objective-C: Reading a file line by line

I am going to read about 2000 lines of sql queries when the application launch if there is a new data migration. This will probably one happen once each 2nd month or so. Could I use this selector and just split the lines, put them in an array and loop through each index to execute the sqlite3 function, or would this take to much time?

+ (id)stringWithContentsOfFile:(NSString *)path 
      encoding:(NSStringEncoding)enc 
      error:(NSError **)error
Community
  • 1
  • 1
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434

2 Answers2

2

Why don't you try it out?

Seriously though, that is probably fine. 2000 lines of text is what, 200k of data? That isn't all that much.

Simon Goldeen
  • 9,080
  • 3
  • 36
  • 45
1

If possible, I would batch the operation into a transaction to potentially alleviate overhead with running multiple queries, maybe getting some rollback ability in the case of failure. I believe that sqlite has transaction capability.

pzearfoss
  • 3,593
  • 1
  • 16
  • 12