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方法时,我看不到任何调用.我究竟做错了什么?
解决方法 您应该实现浏览器:dIDNotStartbrowsingForPeers:delegate方法.如果调用它,您收到的NSError对象将帮助您诊断问题.- (voID)browser:(MCNearbyServicebrowser *)browser dIDNotStartbrowsingForPeers:(NSError *)error{ NSLog( @"Unable to start browsing for peers. Error: %@",error );}总结
以上是内存溢出为你收集整理的ios – 使用MCNearbyServiceBrowser时找不到广告商全部内容,希望文章能够帮你解决ios – 使用MCNearbyServiceBrowser时找不到广告商所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)