我在Swift IOS9.2上使用PubNub 4.2.5,收到了这个错误信息,有没有什么办法resolve..thanks!
/Users/XXXX/xcode/XXXX/PubNub5/PubNub5/AppDelegate.swift:91:10: Objective-C method 'client:didReceiveStatus:' provided by method 'client(_:didReceiveStatus:)' conflicts with optional requirement method 'client(_:didReceiveStatus:)' in protocol 'PNObjectEventListener'函数
//Handle subscription status change.
func client(client: PubNub!, didReceiveStatus status: PNSubscribeStatus) {
}发布于 2016-02-07 07:34:59
PubNub订阅iOS SDK监听器
适当的类应该是PNSubscribeStatus。
完整的订阅代码喜欢下面的代码。请参阅full docs for PubNub iOS Swift SDK v4.x subscribe API。
self.client?.subscribeToChannels(["my_channel1","my_channel2"], withPresence: false)
// Handle new message from one of channels on which client has been subscribed.
func client(client: PubNub!, didReceiveMessage message: PNMessageResult!) {
// Handle new message stored in message.data.message
if message.data.actualChannel != nil {
// Message has been received on channel group stored in
// message.data.subscribedChannel
}
else {
// Message has been received on channel stored in
// message.data.subscribedChannel
}
print("Received message: \(message.data.message) on channel " +
"\((message.data.actualChannel ?? message.data.subscribedChannel)!) at " +
"\(message.data.timetoken)")
}
// Handle subscription status change.
func client(client: PubNub!, didReceiveStatus status: PNSubscribeStatus!) {
if status.category == .PNUnexpectedDisconnectCategory {
// This event happens when radio / connectivity is lost
}
else if status.category == .PNConnectedCategory {
// Connect event. You can do stuff like publish, and know you'll get it.
// Or just use the connected event to confirm you are subscribed for
// UI / internal notifications, etc
}
else if status.category == .PNReconnectedCategory {
// Happens as part of our regular operation. This event happens when
// radio / connectivity is lost, then regained.
}
else if status.category == .PNDecryptionErrorCategory {
// Handle messsage decryption error. Probably client configured to
// encrypt messages and on live data feed it received plain text.
}
}https://stackoverflow.com/questions/35216206
复制相似问题