将结果从静态库类发送到被调用的对象(类)

发布于 2024-12-29 12:34:55 字数 132 浏览 4 评论 0原文

我有 ios 项目,其中有用于启动 Web 服务请求并解析其响应的静态库。 现在的问题是,当我从 ios 主项目类调用静态库的方法时,我希望调用类等到被调用的类执行所有操作。我尝试使用线程但没有运气。有人可以帮助我吗?

谢谢, PMB

I have ios project in which I am having static library for initiating webservice request and parsing the response of it.
Now the problem is when I call the method of static library from ios main project class, I want the calling class to wait until the called class performs it's all actions. I tried by using thread but no luck. Anyone can help me?

Thanks,
PMB

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

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

发布评论

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

评论(1

乖乖 2025-01-05 12:34:55

你的问题需要更多细节 Pooja,因为很多答案取决于你如何实现。

如果您可以控制“静态库”(意味着您可以对其进行代码更改),我建议实现一个回调函数(或者甚至是一个委托方法......不能 100% 确定这对于静态库是可能的,但无论如何)。然后,当库在主线程上回调 UI 时,所需要做的就是调用该回调函数或方法。

如果您无法控制“静态库”,我建议在单独的线程中吐出对静态库的调用(听起来您已经完成了),并在该单独的线程中设置一个计时器方法每秒触发一次或以其他方式查看静态库是否“执行了所有操作”(正如您所说)。

到目前为止,这种方法听起来怎么样?

Your question needs some more detail Pooja, as a lot of the answer depends on how you've implemented things.

If you have control over the "static library" (meaning you can make code changes to it), I recommend implementing a callback function (or maybe even a delegate method... not 100% certain that this is possible with a static library, but anyways). Then when it's time for the library to call back the UI on the main thread, all that needs to be done is call that callback function or method.

If you don't have control over the "static library", I'd recommend spitting off the calls to the static library in a separate thread (which it sounds like you've already done) and set a timer method in that separate thread to fire every second or whatever to see if the static library has "performed all it's actions" (as you said).

How does that approach sound so far?

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