Metman
Metman

Reputation: 346

Swift 4.2: Cannot convert value of type 'Notification' to expected argument type 'Notification'

I can't understand what's wrong with code.
I use native method for final merge context.

@objc func mergeContext(notification: Notification) {
        let sender = notification.managedObjectContext

        if sender != mainThreadManagedObjectContext {
            mainThreadManagedObjectContext.performAndWait {
                [unowned self] in

           self.mainThreadManagedObjectContext.mergeChanges(fromContextDidSave: notification)
            }
        }
    }

Upvotes: 0

Views: 487

Answers (1)

Joakim Danielson
Joakim Danielson

Reputation: 51892

Here Notification clearly is a subclass of NSManagedObject

let sender = notification.managedObjectContext

but this method mergeChanges(fromContextDidSave:) expects a swift class Notification so you are probably calling the wrong function

Upvotes: 3

Related Questions