开发者

netServiceBrowserDidStopSearch not called

开发者 https://www.devze.com 2022-12-28 02:02 出处:网络
I\'m now writing a Bonjour service listener class, according to the document here: Currently, it seems working, I can receive \"netServiceBrowserWillSearch:\" and \"didFindService:moreComing:\" corre

I'm now writing a Bonjour service listener class, according to the document here:

Currently, it seems working, I can receive "netServiceBrowserWillSearch:" and "didFindService:moreComing:" correctly. However, after a long wait, 开发者_运维技巧I cannot receive " netServiceBrowserDidStopSearch:" or "netServiceBrowser:didNotSearch:". Therefore I don't know that is the proper time for my delegate class to stop showing some UI.

Could anyone have an idea for this? Thanks.


NSNetServiceBrowser doesn't stop browsing (and call the -netServiceBrowserDidStopSearch: delegate method) until you explicitly tell it to by calling -stop. After it's found the initial services, it continues informing you as new matching services are added or old ones disappear.

How you handle this depends on how you want your app to behave. If you have a window that continuously shows the available services (e.g. like the Bonjour window in iChat), then it's best to let it continue, and contiuously update the list in response to delegate messages. If you've got more like a dialog that gets populated and then goes away once the user makes a selection (e.g like the system Add Printer... dialog), then you want to keep the browser running while it's displayed, then call -stop once the user dismisses it. If you're waiting to find just one specific service, then you can call -stop once you've found and resolved it.

0

精彩评论

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