gpt4 book ai didi

swift - 无法在 Swift 中转换为 NSMutableString

转载 作者:行者123 更新时间:2023-11-30 11:49:37 27 4
gpt4 key购买 nike

我有这样的 Swift 结构:

if(isSearching == true){
let contactDict :NSDictionary = self.filteredArray?.object(at: indexPath.row) as! NSDictionary;
let strArray :NSArray = contactDict.object(forKey: kName) as! NSArray
nameString = strArray.componentsJoined(by: "") as! NSMutableString

//nameString = (contactDict.object(forKey: kName) as? String as! NSMutableString)
companyNameString = (contactDict.object(forKey: kCompanyName) as AnyObject).object(at: 0) as? NSString;
designationString = (contactDict.object(forKey: kDesignation) as AnyObject).object(at: 0) as? NSString;
profileImage = contactDict.object(forKey: kProfilePic) as? UIImage;
connectStatus = contactDict.value(forKey: kLinkStatus) as? NSString;

if(profileImage?.accessibilityIdentifier == "Img_placeholder"){
profileImage = nil;
}

错误显示如下:

Could not cast value of type 'NSTaggedPointerString' (0x1b5b89900) to 'NSMutableString' (0x1b5b959c0)

如何解决这个问题?

最佳答案

如果您需要 nameString 成为 NSMutableString,请尝试以下操作:

nameString: NSMutableString = strArray.componentsJoined(by:"").mutableCopy()

关于swift - 无法在 Swift 中转换为 NSMutableString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48473764/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com