3

I'm having trouble getting the summaryText on a message to consistently display the name associated with the UUID that is passed forward. When it fails to work only an empty string is displayed in its place.

        let local = activeConversation!.localParticipantIdentifier
        let remote = activeConversation!.selectedMessage!.senderParticipantIdentifier

                if winningPlayer.id == localPlayer!.id {
                    layout.subcaption = "$\(local) wins!"
                    message.summaryText = "$\(local) won \(scoreForLocalPlayer()) - \(scoreForRemotePlayer())"
                }
                else {
                    layout.subcaption = "$\(remote) wins!"
                    message.summaryText = "$\(remote) won \(scoreForRemotePlayer()) - \(scoreForLocalPlayer())"
                }

What's especially strange here is that the layout.subcaption always shows the correct name, but the message.summaryText usually only displays " won 1 - 0" rather than the expected "(Winning Player's Name) won 1 - 0"

  • What is the type of `local`? – alexburtnik Oct 13 '16 at 19:30
  • I mean if it's a string, you can just concatenate those strings like `local + " won \(localScore()) - \(remoteScore())"` – alexburtnik Oct 13 '16 at 19:34
  • So `local` and `remote` are UUIDs that come from the `MSConversation` object and that fancy syntax with $\ is some sort of magic that messages uses to convert that to the matching name in Contacts because security and such. – Stephen Newton Oct 14 '16 at 13:18
  • Ok, some inner voice is telling me that you should use that $ magic in a separate string and then use it in your formatting – alexburtnik Oct 14 '16 at 13:21

0 Answers0