Wednesday, October 28, 2026
HomeiOS Developmentios - onAppear for views created in a storyboard

ios – onAppear for views created in a storyboard

[ad_1]

I’m utilizing a library, which is extra tailor-made in the direction of Swift UI, however I’m creating app based mostly on common Views and ViewControllers.
The article for that library have to be declared(not less than from my understanding) it as both @StateObject or @ObservableObject, I get the identical error for each:

Accessing StateObject’s object with out being put in on a View. It will create a brand new occasion every time.

From comparable points, the answer appears to be to make use of .onAppear(Accessing StateObject’s object with out being put in on a View. It will create a brand new occasion every time – SwiftUI), however I’m misplaced on tips on how to name .onAppear for an @IBOutlet
Is there a method to name .onAppear for a view, which is said as:

@IBOutlet var hostView: CPTGraphHostingView!

?

UPDATE

If I declare the thing as

var conductor = TunerConductor()

The Tuner Conductor errors out with the identical throw within the initialization part:

  init() {
    print("init began ")
    guard let enter = engine.enter else { fatalError() }

    guard let gadget = engine.inputDevice else { fatalError() }
    print("enter chosen")
    initialDevice = gadget

    mic = enter
    tappableNodeA = Fader(mic)
    tappableNodeB = Fader(tappableNodeA)
    tappableNodeC = Fader(tappableNodeB)
    silence = Fader(tappableNodeC, acquire: 0)
    engine.output = silence
    print("objects init")
    tracker = PitchTap(mic) { pitch, amp in
        DispatchQueue.primary.async {
            self.replace(pitch[0], amp[0])
        }
    }
    
}

Output appears to be like like:

init began

2022-04-22 17:53:21.604952-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606254-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606352-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606437-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606514-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606606-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606685-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606764-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.606839-0700 SING[9300:646252] throwing -10878

enter chosen

2022-04-22 17:53:21.615502-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.615950-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.616028-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.616097-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.616167-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.616237-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.616320-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.616396-0700 SING[9300:646252] throwing -10878
2022-04-22 17:53:21.616471-0700 SING[9300:646252] throwing -10878

objects init

There aren’t any mentions of this error code within the library nor in swift typically, so I’m misplaced what can it’s.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments