Skip to content

Instantly share code, notes, and snippets.

@PaulWoodIII
Created August 5, 2019 01:11
Show Gist options
  • Select an option

  • Save PaulWoodIII/e04cee8490678b4c51243961a34a4202 to your computer and use it in GitHub Desktop.

Select an option

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
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
}
}
}
@PaulWoodIII
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment