---
title: "init(id:)"
framework: tipkit
role: symbol
role_heading: Initializer
path: "tipkit/tips/event/init(id:)-99edo"
---

# init(id:)

Creates an event.

## Declaration

```swift
init(id: String) where DonationInfo == Tips.EmptyDonation
```

## Parameters

- `id`: Unique identifier for persisting the event and its donations.

## Creating an event

Creating an event Create an event when you want display a tip based on an action that can occur one or more times in your app (such as a user logging in). Then use donate() to donate to the event when the action occurs, increasing the event count by one. struct LandmarkDetailView: View {     let landmark: Landmark

var body: some View {         VStack {             Text(landmark.name)             Text(landmark.description)         }         .task {             let donationInfo = DidViewLandmark(landmarkName: landmark.name)             await Self.didViewLandmark.donate(donationInfo)         }     }

static let didViewLandmark = Event(id: "didViewLandmark") } Adding event rules Add tip display rules using the #Rule macro to prevent a tip from being displayed until an event has been donated a specific number of times. struct FavoriteLandmarkTip: Tip {     var rules: [Rule] {         // Tip will only display when the didViewLandmark event has been donated 3 or more times.         #Rule(LandmarkDetailView.didViewLandmark) {             $0.donations.count >= 3         }     } }

## Topics

### Properties

- [donations](tipkit/tips/event/donations.md)

### Add Donations

- [donate()](tipkit/tips/event/donate().md)
- [donate(_:)](tipkit/tips/event/donate(_:).md)
- [sendDonation(_:)](tipkit/tips/event/senddonation(_:).md)
- [sendDonation(_:_:)](tipkit/tips/event/senddonation(_:_:).md)
