One Logo Pool Ball
Combine · IOS API REFERENCE

ObservableObject

protocol · iOS 13.0+ · SDK 27.1

protocol ObservableObject : AnyObject

A type of object with a publisher that emits before the object has changed. By default an ``ObservableObject`` synthesizes an ``ObservableObject/objectWillChange-2oa5v`` publisher that emits the changed value before any of its `@Published` properties changes. class Contact: ObservableObject { @Published var name: String @Published var age: Int init(name: String, age: Int) { self.name = name self.age = age } func haveBirthday() -> Int { age += 1 return age } } let john = Contact(name: "John Appleseed", age: 24) cancellable = john.objectWillChange .sink { _ in print("\(john.age) will change") } print(john.haveBirthday()) // Prints "24 will change" // Prints "25"

Members (1)

get · iOS 13.0+

objectWillChange

Swift declaration
var objectWillChange: ObservableObjectPublisher { get }

Skipped declarations

No declarations were skipped in this snapshot.

All Combine types →