我需要保留 NSAlert AlertDidEnd 的 contextInfo 吗?

发布于 2024-12-11 12:30:33 字数 316 浏览 5 评论 0原文

我需要将带有几个选项的 NSDictionary 传递给

NSAlert - (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)modalDelegate didEndSelector:(SEL)alertDidEndSelector contextInfo:(void *)contextInfo

文档没有说明是否必须保留 contextInfo。现在,我在显示警报之前保留它并在 alertDidEnd: 中释放它,但最好确定是否有必要这样做。

I need to pass an NSDictionary with a couple of options to

NSAlert - (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)modalDelegate didEndSelector:(SEL)alertDidEndSelector contextInfo:(void *)contextInfo

The docs don't say anything about if the contextInfo has to be retained or not. Right now I'm retaining it before showing the alert and releasing it in alertDidEnd:, but it would be nice to know for sure if that is necessary.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反目相谮 2024-12-18 12:30:33

由于 contextInfo 被认为是“原始”C 指针 (void *) 并且可以是任何内容,因此管理内存是您的责任(如果您传递的是 Objective- C对象:保留它)。

Since contextInfo is considered to be a "raw" C pointer (void *) and can be anything, it's your responsibility to manage memory (if you're passing an Objective-C object: to retain it).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文