Error in Swift: property not initialized at super.init call
Hello! I'm new to Swift and encountered an error I can't understand. I'm writing a simple notes app. I have a base class `Note` and a subclass `TaskNote` that adds a deadline date. Here's the code:
```swift
class Note {
var title: String
var content: String
init(title: String, content: String) {
self.title = title
self.content = content
}
}
class TaskNote: Note {
var deadline: Date
init(title: String, content: String, deadline: Date) {
self.deadline = deadline
super.init(title: title, content: content)
}
}
```
When compiling, Xcode gives the error: "Property 'self.deadline' not initialized at super.init call". I thought I should assign the new property first, then call...
No answers yet.
Log in to leave an answer