GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

Day 12.3, super.init failure - error not in tutorial...

Forums > 100 Days of SwiftUI

see error reported on xCode 15.4, error not in tutorial. Any ideas?

class Vehicle {
    let isElectric: Bool

    init (isElectric: Bool) {
        self.isElectric = isElectric
    }
}

class Car: Vehicle {
    let isConvertible: Bool

    init(isConvertible: Bool) {
        self.isConvertible = isConvertible
        super.init(isElectric: isElectric) Error: 'self' used in property access 'isElectric' before 'super.init' call
       }
}

1      

Take another look at Paul's code; you don't have yours exactly the same. There is something crucial missing from your version. Match Paul's and the error will go away.

1      

Hacking with Swift is sponsored by Alex.

SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!

Try for free!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.