I am using the latest Swift documentation to write NetService, which am able to publish and search. But I am unable to remove service from the publisher. Not able to understand the role of RunLoop here. However, if I kill the app then service is getting removed.
This is the code am using to publish the service.
class ServicePublisher : NSObject {
var nsNetService : NetService!
init?(domain : String, type : String, name : String, port : Int32){
nsNetService = NetService(domain: domain, type: type, name: name, port: port)
if nsNetService == nil{
return nil
}
}
func publish() {
nsNetService.publish(options:NetService.Options.listenForConnections)
}
func setDelegate(delegate : NetServiceDelegate) {
nsNetService.delegate = delegate
}
func stop(){
nsNetService.stop()
}
}