Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Error in Swift class: Property not initialized at super.init call

In Swift, when calling super.init in a subclass, you must also provide all required parameters to the superclass's initializer.

Quick Answer: Pass all required parameters to the superclass's initializer in the subclass's init call.

The error you're encountering in your Swift classes is due to the fact that you're calling `super.init(name:name)` without providing any parameters. The `init` method of a superclass doesn't take any arguments, so this call is invalid.

🔧 Fixing the Issue

  • Modify the `init` method of your `Square` class to not call `super.init(name:name)`. Instead, simply initialize the properties directly.

💡 Example

Modified Square Class

  1. init: The `super.init` call is removed, and the properties are initialized directly.
class Shape {} // unchanged
class Square: Shape {    var sideLength: Double    init(sideLength:Double) {        self.sideLength = sideLength        numberOfSides = 4    }    func area () -> Double {        return sideLength * sideLength    }} // Note that we've removed the 'name' parameter from the init call

🔧 Testing Your Code

Once you've made these changes, compile and run your code to test that it's working as expected.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions