Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我如何从 SIMBL 插件中获取主应用程序中的单例?当我尝试调用类似的东西[ProcessControl sharedInstance]时,我收到一个错误,即 ProcessControl 未定义(即使它是在头文件中声明的)。
[ProcessControl sharedInstance]
用于NSClassFromString在运行时查找类,然后sharedInstance正常发送消息。
NSClassFromString
sharedInstance
准备好NSClassFromString返回Nil或传递给班级的信息失败。如果应用程序开发人员删除或重命名类或其单例方法,则会发生任何一种情况。每当您为没有记录的、受支持的插件 API 的应用程序编写插件时,您就承担了这种风险。
Nil
如果与应用程序的类及其实例交互的所有代码看起来完全偏执,那么您的“插件”将是最强大的。