We are using following code to inform user about peer to peer connection state. But there is a problem "labelState.text = state.displayName
" changes label text almost 10 seconds after " println ("State Changed to \(state.displayName)
" is showed the state. Is there anyone faces the same problem.
func session(session: MCSession!, peer peerID: MCPeerID!, didChangeState state: MCSessionState)
{
println("State Changed to \(peerID.displayName)")
labelState.text = peerID.displayName
}
MCSessionDelegate
callbacks do not come on the main thread. If you are making UI changes in that function you need to do so on the main thread.You should also be using
displayName
on theMCPeerID
object not theMCSessionState
which is just an enum.