iphone - Objective-C:在 iOS 中转发消息

标签 iphone objective-c ios forwarding

是否可以在 iOS 中使用“转发”(http://en.wikipedia.org/wiki/Objective-C#Forwarding)?

我尝试了以下我发现的代码 here :

- (retval_t) forward: (SEL) sel : (arglist_t) args

但是我收到一条错误消息:

error: expected ')' before 'retval_t'

所以我读了here并尝试:

- (retval_t)forward:(SEL)sel args:(arglist_t) args

但是我得到了同样的错误信息...

我做错了什么?我需要导入什么吗?


@bbum:我尝试创建一个线程安全的 NSMutableArray 并想使用我在这里找到的代码: NSMutableDictionary thread safety

最佳答案

是的。您在这里看到的是 Objective-C 的 GNU 变体,它与 Apple 变体略有不同。

您想使用 -forwardInvocation: 而不是 -forward::-forward:args:。参见 http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtForwarding.html有关如何使用 iOS 执行此操作的更多信息。

关于iphone - Objective-C:在 iOS 中转发消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6986170/

相关文章:

ios - React-native iOS 构建失败

ios - CustomPushHandler 代表不被称为深度链接 Urban Airship

ios - 在 iOS 中截取 UIView 的屏幕截图

ios - 如何从共享扩展中的主容器项目导入文件?

ios - 如何在两个标签之间调整 UIDatePicker 的大小

Iphone UIView 切换 : Previous view's subviews polluting newly switched-to view

iphone - UIScrollview缩放刷新内容

Iphone:如何在 Objective C 中创建 json

iphone - iphone 应用程序 Beta 测试人员需要开发者许可证吗?

ios - ABPeoplePickerNavigationController。需要在同一个 View Controller 中显示联系人