简体   繁体   中英

iOS Swift: Value of type 'NotificationCenter' has no member 'publisher'

I'm trying to use the new Combine framework with the Notification Center as Apple explained in this video: https://developer.apple.com/videos/play/wwdc2019/721/

You can find it in the slide 21.

It seems that my project does not read the Combine framework apis.

import Combine
import Foundation

let trickNamePublisher = NotificationCenter.default.publisher(for: .newTrickDownloaded)

And i'm getting this error:

Value of type 'NotificationCenter' has no member 'publisher'

Apparently seems that in Xcode 11 beta there is this know issue:

The Foundation integration for the Combine framework is unavailable. The following Foundation and Grand Central Dispatch integrations with Combine are unavailable: KeyValueObserving, NotificationCenter, RunLoop, OperationQueue, Timer, URLSession, DispatchQueue, JSONEncoder, JSONDecoder, PropertyListEncoder, PropertyListDecoder, and the @Published property wrapper. (51241500)

link: https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_release_notes/

Indeed they weren't using Xcode during that presentation, but just code on slides

This issue has been fixed with Xcode 11 beta 2 . From Xcode 11 Beta 2 Release Notes :

The Foundation integration for the Combine framework is now available. The following Foundation and Grand Central Dispatch integrations with Combine are available: KeyValueObserving, NotificationCenter, RunLoop, OperationQueue, Timer, URLSession, DispatchQueue, JSONEncoder, JSONDecoder, PropertyListEncoder, PropertyListDecoder, and the @Published property wrapper. (51241500)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM