我有一个MultipeerService类,用于启动广告和浏览会话.出于某种原因,我不确定为什么我无法看到任何广告客户.
MultipeerService.m
-(void) startAdvertising { NSString *name = [[UIDevice currentDevice] name]; MCPeerID *peerId = [[MCPeerID alloc] initWithDisplayName:name]; self.session = [[MCSession alloc] initWithPeer:peerId]; self.session.delegate = self; self.advertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:peerId discoveryInfo:nil serviceType:kServiceType]; self.advertiser.delegate = self; [self.advertiser startAdvertisingPeer]; } -(void) startBrowsing { NSString *name = [[UIDevice currentDevice] name]; MCPeerID *peerId = [[MCPeerID alloc] initWithDisplayName:name]; self.session = [[MCSession alloc] initWithPeer:peerId]; self.session.delegate = self; self.browser = [[MCNearbyServiceBrowser alloc] initWithPeer:peerId serviceType:kServiceType]; self.browser.delegate = self; [self.browser startBrowsingForPeers]; }
我启动广告客户,如下所示:
_multipeerConnectivityService = [[MultipeerConnectivityService alloc] init]; [_multipeerConnectivityService startAdvertising];
我创建了一个用于浏览的multipeerConnectivityService的新实例,并调用了startBrowsing方法.
当我在multipeerConnectivityService中检查foundPeer方法时,我看不到任何调用.我究竟做错了什么?