notifications - Warning in Xcode 8: Instance method nearly matches optional requirement -
i trying implement local notifications in ios10, , far it not working.
i warning around delegate methods:
instance method 'usernotificationcenter(_:didreceive:withcompletionhandler:)' matches optional requirement 'usernotificationcenter(_:didreceive:withcompletionhandler:)' of protocol 'unusernotificationcenterdelegate'
as solution xcode suggests 2 options: 1.make private 2.make @nonobjc
why that? why need it? , important, how make these methods work?
xcode 8 beta 6 introduced many swift 3 changes, 1 of @escaping
keyword mark closures might used after method returns. completion handlers escaping closures, because might show information user, wait feedback, , then call completion handler – method return , keep reference closure, rather blocking.
i expect there xcode 8 gm issued in next few hours, right xcode doesn't insert @escaping
attribute it's needed, what's causing error. 2 fix-its being offered red herrings, i'm afraid.
try writing method instead:
func usernotificationcenter(_ center: unusernotificationcenter, didreceive response: unnotificationresponse, withcompletionhandler completionhandler: @escaping () -> void) {
edit: xcode 8 gm available, , correctly inserts @escaping
when needed.
Comments
Post a Comment