Search code examples
objective-cimessage

Getting names of participants MSConversation


I am developing an iMessage app where I need to get the names of participants of a conversation. In the WWDC Session iMessage Apps and Stickers, Part 2 (link), they are explaining how to do that in Swift via String interpolation :

layout.caption = "$\(conversation.localParticipantIdentifier.uuidString) likes Sprinkles!"

The thing is I want to do the same in Objective-C and I can't find any documentation on how to perform string interpolation in Objective-C or how to achieve showing the name of the participants.

I have tried

[layout setCaption:[NSString stringWithFormat:@"$\(%@)",conversation.localParticipantIdentifier.UUIDString]];

but it is showing the entire UUID instead of the participant name. There must be a Objective-C way!

Am I doing something wrong?

Thanks for your help.


Solution

  • OK. I found the solution.

    I just needed to add a dollar sign before the UUID.

    [layout setCaption:[NSString stringWithFormat:@"$%@",self.activeConversation.localParticipantIdentifier.UUIDString]];