0

同じドメインと名前でnetServiceオブジェクトを1回公開しています。myServiceとして私のサービスを見つける別のデバイス。

しかし、再び同じドメインと名前でnetServiceオブジェクトを公開します。別のデバイスが私のデバイスをmyService(1)として検出します。

コード:

self.netService = [[NSNetService alloc] initWithDomain:domain type:protocol name:name port:self.port];
if(self.netService == nil)
    return NO;

[self.netService scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
****[self.netService publish];****
[self.netService setDelegate:self];

公開ごとに、デバイス名を一意にする方法を教えてください。

4

1 に答える 1

1

これには一意のデバイス ID を使用できます。

NSString* deviceID = [ UIDevice currentDevice ].uniqueIdentifier;
于 2011-05-31T11:46:23.567 に答える