1
私はこの機能を持っている:Delphi/IOS imp_implementationWithBlockを正しく使用するには? IOSでは
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
私の特定の問題は、このPARAMです:
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
私は
procedure userNotificationCenterWillPresentNotificationWithCompletionHandler(center: UNUserNotificationCenter;
willPresentNotification: UNNotification;
withCompletionHandler: pointer);
var aImp: procedure(self: pointer; _cmd: pointer; const options); cdecl;
aOptions: UNNotificationPresentationOptions;
begin
@aImp := imp_implementationWithBlock(withCompletionHandler);
aOptions := UNNotificationPresentationOptionAlert;
aImp(self, nil, aOptions);
imp_removeBlock(@aImp);
end;
のようにそれを翻訳し、それが動作していません!私
をオプションを渡すとき、私は
var aImp: procedure(self: pointer; _cmd: pointer; const options); cdecl;
aOptions := UNNotificationPresentationOptionAlert;
が、そうでないかもしれない良い方法のように、IMPの機能を宣言しない事間違って何か、私は
var aImp: procedure(self: pointer; _cmd: pointer; options: pointer); cdecl;
aOptions := pointer(UNNotificationPresentationOptionAlert);
かのようにそれを宣言してみてくださいlike
var aImp: procedure(self: pointer; _cmd: pointer; options: nsuinteger); cdecl;
aOptions := UNNotificationPresentationOptionAlert;
いいえ仕事:(私のアイデアミス?
これは、Appleのドキュメントに矛盾であるように思わ:https://developer.apple.com/reference/objectivec/1418587-imp_implementationwithblock?language=objcが、私はあなたが答えを見つけてうれしいです! –