Created
August 5, 2019 01:11
-
-
Save PaulWoodIII/e04cee8490678b4c51243961a34a4202 to your computer and use it in GitHub Desktop.
It isn't hard to find some numbers that will cause SwiftUI to break down a little
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Item: View, Identifiable { | |
| let forInt: Int | |
| var id: String { | |
| return "\(forInt)" | |
| } | |
| var body : some View { | |
| //: Make this view more complex | |
| HStack{ | |
| Text("\(forInt)") | |
| } | |
| } | |
| } | |
| struct SimpleList : View { | |
| //: Increase this number | |
| static let max = 100 | |
| let list: [Item] = { | |
| var allItems: [Item] = [] | |
| for i in 0...max { | |
| allItems.append(Item(forInt: i)) | |
| } | |
| return allItems | |
| }() | |
| var body: some View { | |
| List(list) { item in | |
| return item | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It isn't hard to get yourself to a point where you break a List in SwiftUI. It is trivial to program this to see the limits. Anything would break with a list this large contained only in memory though. There is a point where reference types are required to simply handle the load within memory constraints, and databases are need for record keeping to give us a count of objects. This is where NSFetchedResultsControllers shine