swiftnsnotification

type of expression is ambiguous without more context for NSNotification


I have migrated my code from XCode 8.0 to XCode 9.4

Now I am getting this error:

type of expression is ambiguous without more context

private let visageNoFaceDetectedNotification = NSNotification(name: "visageNoFaceDetectedNotification", object: nil)

Everything was working fine in XCode 8.0.

I think because of swift version changed, it is happening.


Solution

  • Swift 4 changed how you create notification names.

    Change your code to:

    private let visageNoFaceDetectedNotification = NSNotification(name: NSNotification.Name(rawValue: "visageNoFaceDetectedNotification"), object: nil)