iOS Development

ios – Calling objectWillChange.ship() produce efficiency points

I’ve a venture with a nested object construction

Venture -> Panels -> Layers

and I’ve SettingsView the place I replace totally different properties of any of those constructions.

On each replace I’ve to name objectWillChange.ship() to see adjustments in View instantly.
If I’ve a small variety of objects it really works superb and produces no efficiency points. But when the variety of objects will increase it makes perf points.

Instance of my code beneath:

class SelectedProjectHolder: ObservableObject {
    @Printed var tasks: [Project] = []
    @Printed var selectedProject: Venture? = nil
    func updateTextLayerColor(for textLayer: TextLayer, newColor: Colour) {
        guard let selectedProject = selectedProject else {
        for (panelIndex, panel) in selectedProject.panels.enumerated() {
            if let layerIndex = panel.textLayers.firstIndex(the place: { $ == }) {
                selectedProject.panels[panelIndex].textLayers[layerIndex].shade = newColor

struct MainApp: App {
    let selectedProjectHolder = SelectedProjectHolder()
var physique: some Scene {
        WindowGroup {
            ContentView(lastSaveTime: lastSaveTime)
        .instructions {

What do I miss and why it does not work with out calling objectWillChange.ship() explicitly?

Is there a strategy to see adjustments instantly with out calling objectWillChange.ship() each time I make adjustments in selectedProject property of SelectedProjectHolder?


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button