开发者

NSNetServiceBrowser delegate not called when searching

开发者 https://www.devze.com 2023-01-12 03:04 出处:网络
I got a really annoying problem. Im trying to search after a NSNetService (that i know exist).I\'ve cop开发者_StackOverflow中文版ied the example code from http://www.macresearch.org/cocoa-scientists-p

I got a really annoying problem. Im trying to search after a NSNetService (that i know exist). I've cop开发者_StackOverflow中文版ied 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).


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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消