列挙中に NSMutableDictionary からキーを削除したいのですが、列挙中に変更したため、アプリがクラッシュします。これはコードです:
for(id key in BluetoothDeviceDictionary) {
UIButton* btn = [BluetoothDeviceDictionary objectForKey:key];
MCPeerID* DevicePeer = [MCPeerID alloc];
DevicePeer = key;
if (DevicePeer.displayName == peerID.displayName) {
[btn removeFromSuperview];NSLog(@"LostPeer!!!!DEL");
CountNumberOfBluetoothDevices = CountNumberOfBluetoothDevices - 1;
[BluetoothDeviceDictionary removeObjectForKey:key2];
}
}
どうすればいいですか?