ios - 快速将字符串格式化为 NSString

标签 ios swift

我正在尝试为不同的标签设置 tableViewCell 属性。但是我不断收到有关字符串的错误。我已经开始像这样连接阵列。

 cell.titleViewLabel.text = arrayNews[indexPath.row].title

但是我一直收到这个错误

cannot assign a value of type nsstring to a value of type string

我如何将上面的标题格式化为 NSString,这样我就不会在 cellForRowAtIndexPath 中收到此错误?还是其他原因?

最佳答案

问题:

问题根源如下:

cell.titleViewLabel.textNSString

arrayNews[indexPath.row].titlestring

解决方案:

您需要将string 转换为NSString。试试下面的语法

cell.titleViewLabel.text = arrayNews[indexPath.row].title as NSString

关于ios - 快速将字符串格式化为 NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29637394/

相关文章:

iphone - 视网膜显示核心图形字体质量

ios - UIWebView 缩放

ios - 为什么不能将 recordAudioURL 分配给 segue.destination 对象?

ios - 由于图像方向而无法检测图像中的面部

ios - Swift Serial Dispatch Block 仅在委托(delegate)后完成

ios - 如何使用 tabBarItems 在 ipad actionSheet 中显示 pickerView

ios - 为 CarPlay 添加自定义 UIScreen

iphone - 根据用户所在国家/地区具有不同功能的应用程序

objective-c - 如何在第一次打开时滚动到 UITableView 中的一行

Swift 递归闭包栈溢出 bug