Abrcd18
Abrcd18

Reputation: 185

Can I call notification function in timer?

I have func which return struct array of randomly generated cryptocurrencies and then passes it to tableView. I've got this error Cannot convert value of type 'NSNotification.Name' to expected argument type 'Notification' Am I heading in the right direction or not?

Upvotes: 0

Views: 50

Answers (1)

David Chopin
David Chopin

Reputation: 3064

A Notification.Name is simply a String. What you need to do is construct a notification using this Name. In your postNotification(notification:) method, you are passing a String, not a Notification.

Try to replace this code: postNotification(notification: Notificator.dataUpdateNotification) with this: postNotification(notification: Notification(name: Notificator.dataUpdateNotification)).

You need to be passing a Notification into this method, but you are passing Notification.Name which is a String, not a Notification.

Upvotes: 2

Related Questions