ios - Delphi/IOS 如何正确使用imp_implementationWithBlock?

标签 ios delphi

在 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);

我的特殊问题是这个参数:

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;

但是不行!我想我在通过 options

时做错了

我像这样声明 imp 函数

var aImp: procedure(self: pointer; _cmd: pointer; const options); cdecl;
aOptions := UNNotificationPresentationOptionAlert;

但也许不是好方法,我试着声明它

var aImp: procedure(self: pointer; _cmd: pointer; options: pointer); cdecl;
aOptions := pointer(UNNotificationPresentationOptionAlert);

或者喜欢

var aImp: procedure(self: pointer; _cmd: pointer; options: nsuinteger); cdecl;
aOptions := UNNotificationPresentationOptionAlert;

没有用 :( 我想念什么?

最佳答案

有点疯狂我是如何找到它的(尝试所有可能和不可能的组合)但我找到了!

var aImp: procedure(options: nsuinteger); cdecl;

是的,就这么简单......

关于ios - Delphi/IOS 如何正确使用imp_implementationWithBlock?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43958633/

相关文章:

ios - 为什么我的UITableViewController页脚高度不会更改?

delphi - 如何在IMAP邮箱中搜索特定的电子邮件?

Delphi ^A 语法 : Documented, 隐含或未记录?

ios - iPhone 应用程序在 didFinishLaunchingWithOptions 之前崩溃

ios - 异步函数返回正常,但数组变为空

ios - 文件在文档目录中保留多长时间(iOS)

ios - Delphi xe4-如何通过HTTP访问Foursquare API

Delphi 7 编译随着时间的推移变得越来越慢?

delphi - 使用 TwebBrowser 可以正常登录站点,但使用 TidHTTP 则不行

ios - 我们怎样才能只从谷歌驱动器 ios 获取文件夹和 pdf 文件