搜索时未调用 NSNetServiceBrowser 委托
我遇到了一个非常烦人的问题。我正在尝试搜索 NSNetService (我知道存在)。我已从 http 复制了示例代码://www.macresearch.org/cocoa-scientists-part-xxviii-bonjour-and-how-do-you-do进入我自己的应用程序。我可以看到(在示例程序中)我的服务已创建。但是当我点击搜索并启动 NSNetServiceBrowser 搜索时,什么也没有发生。更新的委托函数被调用
-(void)netServiceBrowser:(NSNetServiceBrowser *)aBrowser didFindService:(NSNetService *)aService moreComing:(BOOL)more {
我一直在检查诸如我的对象仍然保留之类的东西,并且我看不到任何东西被释放(并且我没有打开GC)。有人知道该怎么做吗?该代码与示例中的完全相同,只是我在它周围添加了一些其他内容(运行 openGL 窗口)。
I got a really annoying problem. Im trying to search after a NSNetService (that i know exist). I've copied the example code from http://www.macresearch.org/cocoa-scientists-part-xxviii-bonjour-and-how-do-you-do into my own application. I can see (in the example program) that my service is created. But when i hit search, and start a NSNetServiceBrowser search, nothing happens. The delegate function newer gets called
-(void)netServiceBrowser:(NSNetServiceBrowser *)aBrowser didFindService:(NSNetService *)aService moreComing:(BOOL)more {
I've been checking stuff like that my objects are still retained, and i can't see that anything is released (and i don't have GC on). Anybody got any ideas what to do? The code is exactly the same as in the example, only i got some other stuff around it (running a openGL window).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题已经很久了(iOS 4/5 时代?),所以我不确定这是否是您的答案,但请确保您仅从应用程序的主线程使用 NSNetServiceBrowser 。
(我不记得它是否也必须在主线程上初始化,或者是否必须从同一线程初始化并调用 -search ,或者是否足以从主线程调用 -search ,但我有完全相同的问题,在我的例子中,它与以某种方式使用后台线程有关。)
This question is eons old (iOS 4/5 era?) so I'm not sure if this is the answer for you, but make sure that you're using NSNetServiceBrowser from the main thread of your application only.
(I can't remember if it also must be initialized on the main thread, or if it must just be initialized and called -search on from the same thread, or if it suffices to call -search from the main thread, but I had the exact same problem and in my case it was related to using a background thread in some way. Sorry for the vague answer.)