<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TipKit",
  "identifier" : "/documentation/TipKit/Tips/Event/init(id:)-3edd4",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "TipKit"
    ],
    "preciseIdentifier" : "s:6TipKit4TipsO5EventV2idAEy_xGSS_tcfc"
  },
  "title" : "init(id:)"
}
-->

# init(id:)

Creates an event with an associated donation value.

```
init(id: String)
```

## Parameters

`id`

Unique identifier for persisting the event and its donations.

## Discussion

### 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()`](/documentation/TipKit/Tips/Event/donate()) to donate to the event when the action occurs, increasing the event count by one.

```swift
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.

```swift
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

[`var donations: [Tips.Event<DonationInfo>.Donation]`](/documentation/TipKit/Tips/Event/donations)

Returns an events existing donations.

### Add Donations

[`func donate() async`](/documentation/TipKit/Tips/Event/donate())

Donates an event with no associated `Donation` value.

[`func donate(DonationInfo) async`](/documentation/TipKit/Tips/Event/donate(_:))

Donates an event along with its associated `Donation` value.

[`func sendDonation((() -> Void)?)`](/documentation/TipKit/Tips/Event/sendDonation(_:))

Asynchronously donates an event with no associated `Donation` value.

[`func sendDonation(DonationInfo, (() -> Void)?)`](/documentation/TipKit/Tips/Event/sendDonation(_:_:))

Asynchronously donates an event along with its associated `Donation` value.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)