gpt4 book ai didi

ios - 为 MSMessage 设置标签或唯一标识符

转载 作者:行者123 更新时间:2023-11-28 06:33:29 26 4
gpt4 key购买 nike

可以为 MSMessage 实例设置唯一的 id 和/或 tag 吗?我当前的应用程序基于使用整数 id 作为标识符从服务器获取的数据。选择上一条消息时,我想相应地修改 View ,方法是获取当前消息的 idtag(如果可能)并在对我的服务器的查询中使用它.

  override func willBecomeActive(with conversation: MSConversation) {
//Retrive id from selected message
if conversation.selectedMessage != nil{
//Do things
}
}

最佳答案

您可以使用消息的 URL 在其中添加一个“id”键:

guard let components = NSURLComponents(string: myBaseURL) else {
fatalError("Invalid base url")
}

let id = NSURLQueryItem(name: "id", value: yourIdHere)
components.queryItems = [id]

guard let url = components.url else {
fatalError("Invalid URL components.")
}

message.url = url

为您的 id 或任何您想要的日期使用哈希值

关于ios - 为 MSMessage 设置标签或唯一标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39650243/

26 4 0