ios – MultiPeer MCNearbyBrowserService崩潰

    我有一個使用MultiPeer連接框架得應用程序.每次應用程序在AppDelegate中變?yōu)榛顒訝顟B(tài)時,我都會創(chuàng)建一個新得MCSession,一個MCNearbyBrowserService和一個MCNearbyAdvertiserService并調(diào)用開始瀏覽并開始廣告.然后,每次應用程序在AppDelegate中變?yōu)榉腔顒訝顟B(tài)時,我都會停止瀏覽和廣告并將所有內(nèi)容設置為零.我發(fā)現(xiàn)MCNearbyBrowserService導致其syncQueue崩潰:
    *** 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];

    我還建議不要在每個應用程序發(fā)布時創(chuàng)建一個新得MCPeerID,因為Multipeer Connectivity習慣于發(fā)現(xiàn)老同行,并且每次重新啟動時你最終都會發(fā)現(xiàn)你得’前??自我’.

    以上是來客網(wǎng)為你收集整理得ios – MultiPeer MCNearbyBrowserService崩潰全部內(nèi)容,希望內(nèi)容能夠幫你解決ios – MultiPeer MCNearbyBrowserService崩潰所遇到得程序開發(fā)問題。

    如果覺得來客網(wǎng)網(wǎng)站內(nèi)容還不錯,歡迎將來客網(wǎng)網(wǎng)站推薦給程序員好友。

    聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進行處理。
    發(fā)表評論
    更多 網(wǎng)友評論1 條評論)
    暫無評論

    返回頂部

    主站蜘蛛池模板: 国产一区二区免费| a级午夜毛片免费一区二区| 人妻夜夜爽天天爽爽一区| 国产精品特级毛片一区二区三区| 内射女校花一区二区三区| 亚洲爆乳无码一区二区三区| 亚洲视频一区在线播放| 日韩AV无码久久一区二区| 亚洲日韩AV一区二区三区中文| 国产香蕉一区二区三区在线视频| 国产精品综合一区二区三区| 在线观看国产一区| 91在线精品亚洲一区二区| 欧美一区内射最近更新| 国产精品 一区 在线| 日韩人妻一区二区三区蜜桃视频| 国产精品综合AV一区二区国产馆| 国产激情一区二区三区四区 | 国产乱码伦精品一区二区三区麻豆| 亚洲福利精品一区二区三区| 精品久久一区二区| 最新欧美精品一区二区三区| 日本精品一区二区三区在线视频一| 国产一区二区精品尤物| 日本一区二区视频| 亚洲av区一区二区三| 亚洲美女视频一区| 人妻无码一区二区视频| tom影院亚洲国产一区二区| 精品在线一区二区三区| 精品无码成人片一区二区98| 午夜无码一区二区三区在线观看| 亚洲制服丝袜一区二区三区| 国产不卡视频一区二区三区| 一区二区无码免费视频网站| 国产免费一区二区三区不卡| 日韩美一区二区三区| 精品国产aⅴ无码一区二区| 亚洲视频在线一区二区| 亚洲AV日韩综合一区| 国产福利精品一区二区|