SwiftUI List performance

39,828 results found

Post not yet marked as solved
1 Replies
I have trided multiple things but I cannot find the solutions. De left side works fine like this: struct LeftSidebar: View { @EnvironmentObject var appState: AppState var body: some View { VStack { List { NavigationLink(destination: HomeMac()) { Label(Home, systemImage: house.fill) } Section(header: Text(SF-symbolen)) { NavigationLink(destination: HomeMac()) { Label(Alle, systemImage: square.grid.2x2) } // NavigationLink(destination: NieuwView()) { // Label(Nieuw, systemImage: star) // } } Spacer() Button(action: { appState.logOut() }) { HStack { Image(systemName: arrow.backward.circle) Text(Loguit) } } } .listStyle(SidebarListStyle()) .frame(minWidth: 50) } .padding() } } var body: some View { ZStack { NavigationView { LeftSidebar() .environmentObject(appState) HomeMac() RightSidebar() } .frame(minWidth: 800, minHeight: 600) } } } But when I want to try this its not working the same.
Post not yet marked as solved
3 Replies
125 Views
Recently we have started refactoring some code to use Swift concurrency in Xcode 15.3. As we have added some new async methods and Tasks, new runtime warnings have emerged titled Known Hang and several are listed. None of the stack traces listed with these warnings are in areas directly modified but some of the same types/methods called are also called from the modified areas. So I can sort of understand why they are coming up...but they had to have been there before we added the Swift concurrency. Example of a tooltip with the warnings: My first query is: Are these warnings only issued when Swift concurrency is added/applied (as they were not there when using closures and mostly just off the main thread to network calls)? The documentation indicates these can all be suppressed by turning off the Thread Performance Checker BUT I would rather just suppress the few places as we refactor our codebase (as it is quite large). In that way, any new ones may be documented and we can decide
Posted
by billdog.
Last updated
.
Post not yet marked as solved
30 Replies
I have tried every single thing listed above and nothing works. Deleted app and restarted my phone after every attempt Tried on wifi and then on cellular tried do not disturb/on off deleted my profiles on xcode and then re-added them None of these work. This is wild that this a real issue. Straight up cannot develop. Xcode: 15.4 osx: 14.5
Post not yet marked as solved
1 Replies
89 Views
Hello, can someone please explain to me how does SwiftUI TabView works under the hood , I don't understand why do all views in TabView get reinitialized each time I switch between tabs. Xcode Version 15.3, iOS 16+ Below is the code snippet : struct ScreenOne: View { init() { print(ScreenOne init called !) } var body: some View { Text(This is screen one!) } } struct ScreenTwo: View { init() { print(ScreenTwo init called !) } var body: some View { Text(This is screen two !) } } struct TabViewTest: View { @State var selectedIndex: Int = 1 var body: some View { TabView(selection: $selectedIndex) { ScreenOne() .tag(1) .tabItem { Text(Item 1) } ScreenTwo() .tag(2) .tabItem { Text(Item 2) } } // .onChange(of: selectedIndex) { oldValue, newValue in // // } // NOTE: When code above is uncommented // Screen one & Screen two initializers get called // each time switch to different tab occurs } } Snippet output with the commented out code : App loads Both print statements get called -> ScreenOne init call
Posted Last updated
.
Post not yet marked as solved
1 Replies
Not an explanation (I am interested to read an authorised analysis, but my understanding is that calling onChange on the State var, leads TabView to reevaluate its content. Why ? That is the question ! A possible reason: as oldValue, newValue change, that forces the TabView to redraw (and reevaluate). Generally, I have noticed it is very hard (and hazardous) to try to guess how SwiftUI works to reevaluate views…
Post not yet marked as solved
1 Replies
592 Views
I have enabled “StrictConcurrency” warnings in my project that uses SwiftUI. I have a Commands struct. It has a Button, whose action is calling an async method via Task{}. This builds without warnings within Views, but not Commands. There the compiler reports “Main actor-isolated property 'body' cannot be used to satisfy nonisolated protocol requirement”. Looking at SwiftUI: In View, body is declared @MainActor: @ViewBuilder @MainActor var body: Self.Body { get } In Commands, body is not declared @MainActor: @CommandsBuilder var body: Self.Body { get } So the common practice of making a Button action asynchronous: Button { Task { await model.load() } } label:{ Text(Async Button) } will succeed without warnings in Views, but not in Commands. Is this intentional? I've filed FB13212559. Thank you.
Posted
by Bolsinga.
Last updated
.
Post not yet marked as solved
1 Replies
The declarations-items endpoint in the DeclarativeManagement CheckIn request returns the set of declarations assigned to the device making the request. The device will use that list to synchronize the set of declarations from the server. It is up to you to decide what to send to the device. One option is to filter the set of declarations to only those that are expected to be active on the device. The other option is to send declarations that use activations to ensure only those relevant to the device are active. For example, say you have one set of declarations for iPads, and one set for iPhones. You could create separate activations for each set with predicates that only evaluate to true for the corresponding hardware. You could then choose to send both sets of declarations to the device and let it decide what gets applied. Or, since the server does know the type of device hardware, it can choose to only send the set of declarations relevant to that hardware. Things get trickier when the factor that
Post not yet marked as solved
1 Replies
66 Views
In Declarative Device Management there is the Get Server Supported Declarations endpoint that is sent via an MDM Check-In request. Is this supposed to return all of the declarations supported by the server, or only the ones that are intended for the device making the request? This seems like a bad choice of naming for that endpoint and, if my assumption is correct it should be named more along the lines of Get Device Declarations Or am I fundamentally misunderstanding DDM and our server should be sending all declarations we have to the device and the device controls them via activations? This seems counter to the pitch around scalability and performance improvements that DDM offers if we have to send literally everything to the device even if it's known to not be needed, and similarly if the device doesn't support it but the server does then obviously(?) the server shouldn't send it to the device.
Posted Last updated
.
Post not yet marked as solved
1 Replies
That used to be true until recently. With the Observable() it is no more true. From StateObject doc: If you need to store a value type, like a structure, string, or integer, use the State property wrapper instead. Also use State if you need to store a reference type that conforms to the Observable() protocol. To learn more about Observation in SwiftUI, see Managing model data in your app.
Post marked as solved
3 Replies
709 Views
I'm using Apple Clang to build a C++ project from the terminal. The following lines are printed when building the project: -- The C compiler identification is AppleClang 15.0.0.15000100 -- The CXX compiler identification is AppleClang 15.0.0.15000100 clang --version and gcc --version commands show me the following: Apple clang version 15.0.0 (clang-1500.1.0.2.5) Target: arm64-apple-darwin23.3.0 Thread model: posix The next function, while valid with other compilers, displays an error for Apple Clang: std::vector read_file() { return {}; } error: non-aggregate type 'std::vector' cannot be initialized with an initializer list return {}; My questions: Am I on the latest Apple Clang version? If not, how can I upgrade to it? So far, I've tried: xcode-select --install command, the result: xcode-select: note: Command line tools are already installed. Use Software Update in System Settings or the softwareupdate command line interface to install updates softwareupdate -l command, the result: Software Update T
Posted Last updated
.
Post not yet marked as solved
5 Replies
112 Views
Gents, dev(il)s, I am looking for a piece of code or principal explanation to realise following: I have a array of struct Item{} Each item has child [Item] in the content view I would like to have a hierarchical displayed tree of my Items and for each Item line I would like to have a button to remove it or add a child item for a selected one I tired List entity, navigation and have no real success. Is anybody there to give me a small guide? Thank you M
Posted Last updated
.
Post not yet marked as solved
5 Replies
I was puzzled by the crash when removing an added item. That had to do with the focus on the TextField… This works more properly: struct FileItem: Identifiable { var name: String var children: [FileItem]? // 👈🏻 Will be nil if child at lowest level of hierarchy ; otherwise for parent, should be [] when no child var id: String { name } } struct ContentView: View { @State var data: [FileItem] = [ FileItem(name: First, children: [FileItem(name: childF1), FileItem(name: childF2)]), FileItem(name: Second, children: [FileItem(name: childS1), FileItem(name: childS2), FileItem(name: childS3)]), FileItem(name: Third, children: [FileItem(name: childT1), FileItem(name: childT2)]) ] @FocusState private var focusedField: String? var body: some View { List($data, children: .children) { $item in HStack { TextField(, text: $item.name) // probleme : le clavier disparait à chaque caractère // Avec focused, on passe au dernier TextField .focused($focusedField, equals: item.name) .task { self.focusedField = item.name }
Post not yet marked as solved
5 Replies
When you add on child line, what do you add ? A child of the parent ? A child of the child ? I need to have both for each line item. So simple! Remove some tests. Here is an updated code… struct ContentView: View { @State var data: [FileItem] = [ FileItem(name: First, children: [FileItem(name: childF1), FileItem(name: childF2)]), FileItem(name: Second, children: [FileItem(name: childS1), FileItem(name: childS2), FileItem(name: childS3)]), FileItem(name: Third, children: [FileItem(name: childT1), FileItem(name: childT2)]), ] @FocusState private var focusedField: String? var body: some View { List($data, children: .children) { $item in HStack { TextField(, text: $item.name) .focused($focusedField, equals: item.name) // avoid keyboard to disappear at each character .task { self.focusedField = item.name } // Text(item.name) // If there are no children, we cannot remove it if item.children != nil { // So it is parent, maybe with no child [] Spacer() Button(Add child) { // let's search its position in data
Post not yet marked as solved
6 Replies
So, that last one FB9997771 was reported as fixed in the 2022 OS rereleases (so, macOS 13 and friends). Thank you for that detail, Quinn. I am very happy to hear that that one is officially fixed. That had caused really odd intermittent failures in unexpected areas within the JDK and had taken us a long time to narrow it down. I will run our tests against macosx 13 and higher to verify the fix. That should’ve been communicated to you but wasn’t. I’m not sure why. I’ll follow-up on that internally, just for my own understanding, but this is all about Apple internal processes so I probably won’t post any more details here. I understand. The other two are still under investigation; I don’t have any further info to share. Thank you for that update. Bug Reporting: How and Why? has a bunch of hints and tips on this front, but probably the best important is this one: If you’re filing a bug against an API, choose Developer Technologies & SDKs at the top level. This is useful. So far I've been filing it under Some