Chapter 18, Custom Publisher & Ownership
When creating a custom publisher, you also create a custom subscription. In the book ShareReplay example, the ShareReplay subscription owns a reference to the subscriber, but I don’t see that it holds...
View ArticleHow do i observe an Array when append or remove element with Combine?
When I adding or removing element in names array, no any result. following the code. Could you give and advice? class SomeClass: NSObject { @objc var names = ["A", "B", "C"] var cancellable:...
View ArticleChapter 2: Question about notification
I do a simple notification test with combine. Click postNotification button in ViewController that received notification successful. Click removeReceiver button (set _receive to nil) in ViewController...
View ArticleChapter 2: error when I try to run playground
I see the following error at the top of xcode when I try to run the playground: Failed to launch process. Failed to compile sandbox profile: sandbox_extension_issue_file: Operation not permitted I get...
View ArticleSpelling Error Chapter 20
Hi There - Noticed that SwiftUI is missing an ‘I’ character in this note. 3 posts - 2 participants Read full topic
View ArticleAre there more book updates coming?
Hi, The last version of this book was Jul 19, 2023 · iOS 16, Swift 5.8, Xcode 14. Just wondering if this will be updated for iOS 17 / 18 or is another book being created? Thanks. 2 posts - 2...
View ArticleHow to use @Observable to publish a class' properties
I have tried to modify ColorCalc in chapter 19 to use @Observable for the CalculatorViewModel. There were several issues which I could not solve. Can no longer use @Published for properties. Cannot...
View ArticleChapter 2: Bridging Combine Publishers to async/await
Why does this code snippet produces different results? example(of: "async/await") { let subject = CurrentValueSubject<Int, Never>(0) Task { for await element in subject.values { print("Element:...
View ArticleChapter 4. Finding Values `last(where:)`
example(of: "last(where:)") { enum MyError: Error { case test } let subject = PassthroughSubject<Int, MyError>() subject .eraseToAnyPublisher() .last(where: { $0 % 2 == 0 })...
View ArticleChapter 2: Hello Future
In the “Hello Future” the output should be: ——— Example of: Future ——— Original 2 finished Second 2 Second finished However, I get this output: ——— Example of: Future ——— Original Second 2 Second...
View Article