*** Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: '*** - [__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]'*** First throw call stack:(0x2de3ee8b 0x381396c7 0x2dd7caef 0x2dd7c8b3 0x2f648167 0x2f6493af 0x3861e103 0x38622e77 0x3861ff9b 0x38623751 0x386239d1 0x3874ddff 0x3874dcc4)libc++abi.dylib: terminating with uncaught exception of type NSException
有时当应用程序重新打开时.
这是applicationDIDBecomeActive的代码:
self.myIDentifIEr = [[MCPeerID alloc] initWithdisplayname:[self.class createHash:20]];self.mainSession = [[MCSession alloc] initWithPeer:self.myIDentifIEr];self.mainSession.delegate = self;peerAdvertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:self.myIDentifIEr discoveryInfo:nil serviceType: service];peerAdvertiser.delegate = self;peerbrowser = [[MCNearbyServicebrowser alloc] initWithPeer:self.myIDentifIEr serviceType: service];peerbrowser.delegate = self;acceptreset = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(reset) userInfo:nil repeats:YES];acceptposts = true;[peerbrowser startbrowsingForPeers];[peerAdvertiser startAdvertisingPeer];self.isbrowsing = true;
这是我的applicationWillResignActive代码:
[acceptreset invalIDate];[peerAdvertiser stopAdvertisingPeer];[peerbrowser stopbrowsingForPeers];[self.mainSession disconnect];self.mainSession = false;self.isbrowsing = false;
完整代码可在此处查看:http://pastebin.com/E3wY6U4N
解决方法 我记得遇到过这个问题,快速解决方法是让代表们失望并释放浏览器和广告客户.因此,假设您的App Delegate具有强大的属性,每个设置方法将如下所示:self.peerAdvertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:self.myIDentifIEr discoveryInfo:nil serviceType: service];self.peerAdvertiser.delegate = self;self.peerbrowser = [[MCNearbyServicebrowser alloc] initWithPeer:self.myIDentifIEr serviceType: service];self.peerbrowser.delegate = self;
然后当应用程序进入后台(或者想要停止浏览/广告)时:
self.peerAdvertiser.delegate = nil;[self.peerAdvertiser stopAdvertisingPeer];self.peerAdvertiser = nil;self.peerbrowser.delegate = nil;[self.peerbrowser stopbrowsingForPeers];self.peerbrowser = nil;[self.mainSession disconnect];
我还建议不要在每个应用程序发布时创建一个新的MCPeerID,因为Multipeer Connectivity习惯于发现老同行,并且每次重新启动时你最终都会发现你的’前自我’.
总结以上是内存溢出为你收集整理的ios – MultiPeer MCNearbyBrowserService崩溃全部内容,希望文章能够帮你解决ios – MultiPeer MCNearbyBrowserService崩溃所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)