参数转换出现崩溃:
无法将NSStackBlock(0x1030b1e78)类型的值转换为'(__C.UNNotificationPresentationOptions) - > ()'(0x1030b0208)。 2018-02-19 17:40:31.204021 + 0200 [2407:480530]
无法将NSStackBlock类型的值(0x1030b1e78)转换为'(C.UNNotificationPresentationOptions) - > ()'(0x1030b0208)。
extension Reactive where Base: UNUserNotificationCenter {
public var delegate: DelegateProxy<UNUserNotificationCenter, UNUserNotificationCenterDelegate> {
return RxNotificationServiceDelegateProxy.proxy(for: base)
}
var didReceiveResponce: Observable<UNNotificationResponse> {
return delegate.methodInvoked(#selector(UNUserNotificationCenterDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:))).map { parameters in
return parameters[1] as! UNNotificationResponse
}
}
var willPresentNotification: Observable<((UNNotificationPresentationOptions) -> Void)> {
return delegate.methodInvoked(#selector(UNUserNotificationCenterDelegate.userNotificationCenter(_:willPresent:withCompletionHandler:))).map { parameters in
return parameters[2] as! ((UNNotificationPresentationOptions) -> Void) **CRASH!!!**
}
}
}
所有我需要的是在前台显示localNotifications,因此需要相应的委托方法,但无法弄清楚如何这样做我可以将闭包作为参数传递给Observable,或者如果不可能或不需要我将很高兴看到你用RxSwift方式解决这个问题的方法。