简体   繁体   English

如何停止在 wifi 网络中搜索新设备的过程?

[英]How can i stop the process of searching for new devices in wifi network?

in my wifi network code i am using a NSNetServiceBrowser delegate searchForServicesOfType which will starts a search for services of the specified type in the domain indicated by domainString在我的 wifi 网络代码中,我正在使用NSNetServiceBrowser委托searchForServicesOfType它将开始在 domainString 指示的域中搜索指定类型的服务

[ self.netServiceBrowser searchForServicesOfType:types inDomain:domain] [ self.netServiceBrowser searchForServicesOfType:类型 inDomain:domain]

my case type is network identifier(string:" _tcp_wifi ") and domain is " local "(string).我的案例类型是网络标识符(字符串:“ _tcp_wifi ”),域是“本地”(字符串)。

For each service discovered, a -netServiceBrowser:foundService:moreComing: message is sent to the NSNetServiceBrowser instance's delegate.对于每个发现的服务,一个 -netServiceBrowser:foundService:moreComing: 消息被发送到 NSNetServiceBrowser 实例的委托。

- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser didFindService:(NSNetService *)service moreComing:(BOOL)moreComing { } - (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser didFindService:(NSNetService *)service moreComing:(BOOL)moreComing { }

above delegate will trigger for each service discovered.上面的委托将为发现的每个服务触发。

searchForServicesOfType delegate will always search for the new devices. searchForServicesOfType委托将始终搜索新设备。 however i need to stop the process of searching for new devices after 2 minutes using a timer.is it possible do this.is there any NSNetServiceBrowser delegate to do this?但是我需要使用计时器在 2 分钟后停止搜索新设备的过程。是否可以这样做。是否有任何 NSNetServiceBrowser 委托来执行此操作? if yes,can any one tell me the good way to do it.如果是的话,谁能告诉我这样做的好方法。

To stop a search, use the stop method.要停止搜索,请使用 stop 方法。 You should perform any necessary cleanup in the netServiceBrowserDidStopSearch: delegate callback.您应该在 netServiceBrowserDidStopSearch: 委托回调中执行任何必要的清理。

Check this检查这个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用CaptiveNetwork获取可用WiFi网络列表 - How can i get list of available WiFi network using CaptiveNetwork 我如何通过 Wifi 网络传递 NSData object? - How can i pass NSData object over Wifi network? 如何获取当前 wifi 网络中的 Apple 活动设备列表? - How to get the list of Apple active devices in current wifi network? 如何创建一个从iOS应用程序通过WiFi网络接收数据的小型Mac应用程序? - How can I create a small Mac app that receives data over the WiFi network from an iOS app? iOS:我可以手动将 wifi 网络与地理位置关联吗? - iOS: Can I manually associate wifi network with geographic location? iPhone-如何检查即时消息是否已连接到wifi网络 - iphone - how do i check whether im connected to a wifi network 使用GKSession通过不同的WiFi网络连接2个设备 - connecting 2 devices over different WiFi network using GKSession 如何从在 swift 中具有相同 WiFi 网络的不同 iOS 设备将数据从一个应用程序传输到另一个应用程序? - How to transfer data from one app to another app from different iOS devices which have same WiFi network in swift? 即使iPhone上已连接WIFI,我也只能使用蜂窝网络(3G或EDGE)吗? - Can I use only cellular network (3G or EDGE), even if WIFI is connected on the iPhone? 如何将附近的设备编入UITableView并与选定的设备配对? - How can I index nearby devices into a UITableView and pair with the selected devices?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM