One Logo Pool Ball
PaperKit · IOS API REFERENCE

MarkupOrderedSet

struct · iOS 27.0+ · SDK 27.1

struct MarkupOrderedSet

An ordered set of markup elements. The set ensures all elements have unique `id` values.

Members (21)

method · iOS 27.0+

firstIndex

TypeScript
firstIndex(element: SDKHandle): (number) | null
Swift declaration
func firstIndex(of element: MarkupOrderedSet.Element) -> Int?

Returns the index of the given element in the set, or `nil` if the element is not a member of the set. `MarkupOrderedSet` members are always unique, so the first index of an element is always the same as its last index.

get · iOS 27.0+

startIndex

TypeScript
get startIndex(): number
Swift declaration
var startIndex: MarkupOrderedSet.Index { get }

The index of the first element in the set.

method · iOS 27.0+

makeIterator

TypeScript
makeIterator(): MarkupOrderedSet_Iterator
Swift declaration
func makeIterator() -> MarkupOrderedSet.Iterator

Returns an iterator over the elements of the set.

method · iOS 27.0+

removeStroke

TypeScript
removeStroke(id: string): (_PencilKit_PKStroke) | null
Swift declaration
@discardableResult mutating func removeStroke(for id: UUID) -> PKStroke?

Removes the associated stroke for the given id from the set. - Parameter id: The id of the stroke to remove. - Returns: The associated stroke for `id` if the set contains `id`; otherwise, `nil`.

method · iOS 27.0+

removeElement

TypeScript
removeElement(id: MarkupOrderedSet_ElementID): (SDKHandle) | null
Swift declaration
@discardableResult mutating func removeElement(for id: MarkupOrderedSet.ElementID) -> MarkupOrderedSet.Element?

Removes the associated element for the given id from the set. - Parameter id: The id of the element to remove. - Returns: The associated element for `id` if the set contains `id`; otherwise, `nil`.

method · iOS 27.0+

updateOrAppend

TypeScript
updateOrAppend(item: SDKHandle): (SDKHandle) | null
Swift declaration
@discardableResult mutating func updateOrAppend(_ item: MarkupOrderedSet.Element) -> MarkupOrderedSet.Element?

Adds the given element to the set unconditionally, either appending it to the set, or replacing an existing value if one with the same id is present. - Parameter item: The value to append or replace. - Returns: The element this operation replaced, or `nil` if the operation appended the value to the end of the collection.

get · iOS 27.0+

ids

TypeScript
get ids(): MarkupOrderedSet_ElementIDs
Swift declaration
var ids: MarkupOrderedSet.ElementIDs { get }

A view of the set's element ids.

get · iOS 27.0+

count

TypeScript
get count(): number
Swift declaration
var count: Int { get }

The number of elements in the set.

method · iOS 27.0+

index

TypeScript
index(i: number): number
Swift declaration
func index(after i: MarkupOrderedSet.Index) -> MarkupOrderedSet.Index

Returns the index immediately after the given index.

method · iOS 27.0+

append

TypeScript
append(item: SDKHandle): { "inserted": boolean; "index": number }
Swift declaration
@discardableResult mutating func append(_ item: MarkupOrderedSet.Element) -> (inserted: Bool, index: Int)

Appends a new member to the end of the set, if the set doesn’t already contain it. - Parameter item: The element to add to the set. - Returns: A pair (`inserted`, `index`), where inserted is a Boolean value indicating whether the operation added a new element, and `index` is the index of `item` in the resulting set.

method · iOS 27.0+

insert

TypeScript
insert(item: SDKHandle, index: number): { "inserted": boolean; "index": number }
Swift declaration
@discardableResult mutating func insert(_ item: MarkupOrderedSet.Element, at index: Int) -> (inserted: Bool, index: Int)

Inserts a new member at the specified index, if the set doesn’t already contain it. - Parameters: - item: The element to insert. - index: The index to insert at. - Returns: A pair (`inserted`, `index`), where `inserted` is a Boolean value indicating whether the operation added a new element, and `index` is the index of item in the resulting set. If `inserted` is false, then the returned `index` may be different from the index requested.

method · iOS 27.0+

remove

TypeScript
removeAt(index: number): SDKHandle
Swift declaration
@discardableResult mutating func remove(at index: Int) -> MarkupOrderedSet.Element

Removes and returns the element at the specified position. - Parameter index: The position of the element to remove. `index` must be a valid index of the collection that is not equal to the collection’s end index. - Returns: The removed element. The operation moves all elements following the specified position to close the resulting gap.

method · iOS 27.0+

remove

TypeScript
remove(member: SDKHandle): (SDKHandle) | null
Swift declaration
@discardableResult mutating func remove(_ member: MarkupOrderedSet.Element) -> MarkupOrderedSet.Element?

Removes the given element from the set. - Parameter member: The element of the set to remove. - Returns: The element equal to `member` if `member` is contained in the set; otherwise, `nil`.

get · iOS 27.0+

strokes

TypeScript
get strokes(): Array<_PencilKit_PKStroke>
Swift declaration
var strokes: [PKStroke] { get }

The strokes in the set.

method · iOS 27.0+

contains

TypeScript
contains(element: SDKHandle): boolean
Swift declaration
func contains(_ element: MarkupOrderedSet.Element) -> Bool

Returns a Boolean value that indicates whether the given element exists in the set. - Parameter element: An element to look for in the set. - Returns: `true` if member exists in the set; otherwise, `false`.

get · iOS 27.0+

endIndex

TypeScript
get endIndex(): number
Swift declaration
var endIndex: MarkupOrderedSet.Index { get }

The index past the last element in the set.

method · iOS 27.0+

removeAll

TypeScript
removeAll(shouldBeRemoved: ((arg0: SDKHandle) => boolean)): void
Swift declaration
mutating func removeAll(where shouldBeRemoved: (MarkupOrderedSet.Element) throws -> Bool) rethrows

Removes all the elements that satisfy the given predicate. - Parameter shouldBeRemoved: A closure that takes an element of the set as its argument and returns a Boolean value indicating whether to remove the element from the set.

init · iOS 27.0+

init

TypeScript
static init(): MarkupOrderedSet
Swift declaration
init()

Creates a new, empty collection.

subscript · iOS 27.0+

subscript

TypeScript
subscript(id: string): (_PencilKit_PKStroke) | null
Swift declaration
subscript(id: UUID) -> PKStroke? { get set }

Accesses the stroke for the given id.

subscript · iOS 27.0+

subscript

TypeScript
subscript31870(id: MarkupOrderedSet_ElementID): (SDKHandle) | null
Swift declaration
subscript(id: MarkupOrderedSet.ElementID) -> MarkupOrderedSet.Element? { get set }

Accesses the element for the given id.

subscript · iOS 27.0+

subscript

TypeScript
subscript64709(index: number): SDKHandle
Swift declaration
subscript(index: Int) -> MarkupOrderedSet.Element { get }

Accesses the element at the specified position.

Skipped declarations

3 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

MarkupOrderedSet.append(contentsOf:)

This parameter hides a concrete Swift type.

MarkupOrderedSet.removeElement(for:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

MarkupOrderedSet.subscript(_:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

All PaperKit types →