I'm trying to go by the example of the documentation "Keeping a widget up to date" by showing the current time and date, and am using the example below. It throws an error at the let futureDate statement that says, "Cannot use instance member 'components' within property initializer; property initializers run before 'self' is available"
Here's the section of code that's in the EntryView. BTW, the Widget is called CPCWidget.
Here's the section of code that's in the EntryView. BTW, the Widget is called CPCWidget.
Code Block struct CPCWidgetEntryView : View { var entry: Provider.Entry let components = DateComponents(minute: 11, second: 14) let futureDate = Calendar.current.date(byAdding: components, to: Date())! var body: some View { VStack(alignment: .center, spacing: 0) { Text(futureDate, style: .relative) .font(.largeTitle) Text(entry.date, style: .relative) .font(.custom("Times New Roman", size: 20)) } }