One Logo Pool Ball
WidgetKit · IOS API REFERENCE

TimelineEntry

protocol · iOS 14.0+ · SDK 27.1

protocol TimelineEntry

A type that specifies the date to display a widget, and, optionally, indicates the current relevance of the widget's content. A <doc:TimelineProvider> creates one or more timeline entries with dates that tell WidgetKit when to display a widget. To render a widget, WidgetKit executes the `content` block of the widget's configuration, passing the corresponding timeline entry. When you declare a structure conforming to `TimelineEntry`, include any additional information that the configuration’s content block requires to render the widget. The following code shows a timeline entry structure for a widget that displays a game character's health level. struct CharacterDetailEntry: TimelineEntry { var date: Date var healthLevel: Double } The content block of the widget's configuration receives the entry as a parameter and then passes the relevant information to the view that renders your widget. struct CharacterDetailWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration( kind: "com.mygame.character-detail", provider: CharacterDetailProvider()) { entry in CharacterDetailView(entry: entry) } .configurationDisplayName("Character Details") .description("Displays a character's health and other details") .supportedFamilies([.systemSmall, .systemMedium, .systemLarge]) } }

Members (1)

get · iOS 14.0+

relevance

Swift declaration
var relevance: TimelineEntryRelevance? { get }

The relevance of a widget’s content to the user.

Skipped declarations

No declarations were skipped in this snapshot.

All WidgetKit types →