41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
//
|
|
// YinCustomAttachmentCoding.swift
|
|
// yinmeng-ios
|
|
//
|
|
// Created by yinmeng on 2024/3/23.
|
|
//
|
|
|
|
import UIKit
|
|
import MJExtension
|
|
|
|
class YinCustomAttachmentCoding: NSObject,NIMCustomAttachmentCoding {
|
|
func decodeAttachment(_ content: String?) -> NIMCustomAttachment? {
|
|
|
|
if let text = content as? NSString{
|
|
if let data = text.mj_JSONObject() as? [String : Any],let first = data["first"] as? Int,let second = data["second"] as? Int,let dic = data["data"]{
|
|
|
|
if let _dic = dic as? [String : Any]{
|
|
let model = ChatCustomMsgModel()
|
|
model.first = first
|
|
model.second = second
|
|
model.data = _dic
|
|
return model
|
|
|
|
}
|
|
if let _dic = dic as? NSString,let getDic = _dic.mj_JSONObject(),let getData = getDic as? [String:Any]{
|
|
let model = ChatCustomMsgModel()
|
|
model.first = first
|
|
model.second = second
|
|
model.data = getData
|
|
return model
|
|
}
|
|
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
|
|
|
|
}
|