问题
I was wondering if there are any limits on the length of strings stored using Core Data in iOS. (other than available RAM or disk space on the device)
回答1:
I think you're more likely to hit the performance limits on an iOS device before you hit any storage limits in Core Data. You'll also be getting a performance hit from pulling in large chunks of data.
You are better off, both in performance and manageability, breaking up large blocks of text into smaller chunks.
From what I remember Marcus Zarra telling me anyway.
回答2:
Just to confirm, that there are no specific limits in CoreData (not counting memory/disk space limitations). When using CoreData on iOS you are in almost every case using sqlite as persistent storage. CoreData stores String as Varchar and from sqlite's point of view:
SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) and SQLite will be happy to store a 500-million character string there. And it will keep all 500-million characters intact. Your content is never truncated. SQLite understands the column type of "VARCHAR(N)" to be the same as "TEXT", regardless of the value of N.
...taken from sqlite's FAQ
回答3:
It does not have a limit as far as I can tell, unless you assign one in the model file (there is a section for min length and max length).
回答4:
I don't remember reading any limits in Core Data documentations, but remember that Core Data is just a framework on top of a real database, usually sqlite. I think it's safe to assume that the limits are dictated by the underlying DB.
来源:https://stackoverflow.com/questions/10326210/does-core-data-impose-limits-on-the-length-of-strings