如何在 Obj-C/CocoaTouch 中实现插件
我需要一种简单、轻量级的方法来支持我正在编写的 iOS 应用程序中的插件系统。没什么花哨的。这不会向用户公开,而是有助于提高我开发大约 100 个小型(约 50 行代码)代码模块的效率,我允许用户从中进行选择。
我目前严重依赖 plist/NSDictionary 方法,并在 NSDictionary 上添加一个类别以实现附加功能。 plist 是特定于相应插件与之通信的功能的设置字典。我现在想要将插件名称添加为目标/操作对。这是我有点不确定最好的方法的地方。如何指定这个目标/操作对?显然我不想要 100 个子类。也许是协议/委托设计?
谢谢, 道格
I need a simple, lightweight, approach to support a plug-in system in an iOS app I am writing. Nothing fancy. This will not be exposed to the user but rather is a productivity aid for my development of roughly 100 small (~50 lines of code) modules of code that I allow the user to select from.
I currently am leaning heavily on a plist/NSDictionary approach with a category on NSDictionary to additional functionality. The plist is a dictionary of settings specific to functionality that a corresponding plug-in with communicate with. I now want to add the plug-in name as a target/action pair. This is where I am a bit unsure of the best approach. How to I specify this target/action pair? Clearly I don't want 100 subclasses. Perhaps a protocol/delegate design?
Thanks,
Doug
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用和操作是你的朋友。如果您进行传递逻辑数据的自定义操作,它可以使用调用或直接调用模块。通过这种方法,您可以向队列添加大量操作。
Invocations and operations are your friend. If you make a custom operation that is passed logic data it can either use invocations or directly call the modules. With this approach you can add numerous operations to the queue.