ios - 如何从给定图像访问 Json 数据

标签 ios json iphone swift swift3

阵列产品型号detail models

我的代码:

productDetailsNameLabel.text = products[indexPath.section].arr_details?[indexPath.item].productname

获取错误信息:

Type Arr_Details has no subscripts member

最佳答案

arr_details 没有任何下标成员,因此您无法访问它。请引用以下示例:

class Abc: NSObject {
   var arr: [Xyz] = []
   override init() {
       for i in 1...5 {
           arr.append(Xyz(number: i))
       }
   }
}

class Xyz: NSObject {
    var number: Int
    init(number: Int) {
        self.number = number
    }
}
// Use of this class
var arrAbc: [Abc] = []
for _ in 0...5 {
    arrAbc.append(Abc())
}
yourLabel.text = "\(arrAbc[0].arr[0].number)"

关于ios - 如何从给定图像访问 Json 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51437117/

相关文章:

iOS核心数据一对多关系

ios - 检查respondsToSelector 中的属性

ios - Xcode 6 Sprite 套件 - SourceKitService 终止

java - 带有 Jackson token 流的 JSON 中的非常长的字符串(> 1 gig)

xml - 数据效率——以 JSON 或 XML 形式返回?

json - 从输入流中读取时属性的类型不一样

iphone - 使用 iOS 4.2.1 的 3GS 设备上出现奇怪的布局问题 - 使用 iOS 5 编译

android - 计算图像上两点之间的像素

iphone - SearchBar 从 iOS 7 的 headerview 中消失

android - NGUI:如何在实时添加新项目时重置/更新 UIgrid 和 UIScrollBar