【发布时间】:2023-03-07 06:16:02
【问题描述】:
我目前正在使用 MYNetwork 库 Bonjour 类,但在发现 txt 记录时遇到了问题。当一个新服务出现时,它的 txt 记录每次都是空的。
在我的服务器端,我以这种方式设置 txt 记录:
self.server = [[MYBonjourRegistration alloc] initWithServiceType: @"_blipecho._tcp." port:9121];
[server setString:@"Cyprian" forTXTKey:@"Name"];
[server start];
然后在浏览器上我发现并记录数据:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqual:@"services"]) {
NSSet *newServices = (NSSet*)[change objectForKey:@"new"];
if(newServices){
MYBonjourService *service;
for (service in newServices){
textView.text = [NSString stringWithFormat:@"%@\nNew user: %@ (%@)", textView.text, service.name, [service txtRecord]];
}
}
}
我的 txtRecord 为空。
【问题讨论】:
标签: objective-c cocoa networking bonjour