DropSession

A description of a drop that is in progress.

StructureiOS 26.0+macOS 26.0+visionOS 26.0+DropSession in SwiftUI

Declaration

React
type DropSession = { readonly debugDescription: string; readonly id: DropSessionID; readonly itemsCount: number; readonly localSession: DropSessionLocalSession | null; readonly location: CGPoint; readonly phase: DropSessionPhase; readonly size: CGSize; readonly suggestedOperations: DropOperationSet; };
Swift
struct DropSession

Properties

  • debugDescription*string

    A textual representation of this instance, suitable for debugging.

  • The unique identifier of the drop session.

  • itemsCount*number

    Number of items for the drop.

  • localSession*DropSessionLocalSession | null

    Provides additional information about a session if it originated within the app.

  • location*CGPoint

    Location of drop in the local coordinate space

  • The phase of the current drop session.

  • size*CGSize

    Size of the drop destination view.

  • suggestedOperations*DropOperationSet

    Operations suggested by the drag source.

Overview

Read DropSession.location to find where the drop landed, DropSession.itemsCount for how many items it carries, and DropSession.phase to follow the drag through its lifecycle.

The following example animates a drop at the point of the drop:

Color.pink
    .frame(width: 400, height: 400)
    .dropDestination(for: String.self) { titles, session in
        process(titles: titles)
    }

To follow a drag while its phases change, apply View.onDropSessionUpdated(_:).

Use DropSession.localSession to recognize a drag that started inside your own app. It is nil for a drag that came from elsewhere.

From Apple’s SwiftUI documentation. Code samples there are Swift.

Used by

See also

More in Drag and drop.