Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在解析中为tableview分配标题_Ios_Swift_Parse Platform - Fatal编程技术网

Ios 在解析中为tableview分配标题

Ios 在解析中为tableview分配标题,ios,swift,parse-platform,Ios,Swift,Parse Platform,我从parse数据库中获得了许多具有以下数据结构的部分。我不知道如何将其设置为数组,并在swift中的repective tableview部分中正确显示它 第一节标题 小分目 小分目 小分目 小分目 第2节标题 小分目 小分目 小分目 小分目 您的数据结构应该是自定义对象的数组(取决于您的值): 从解析中获取数据后,只需循环解析数据并将其添加到数据结构中: var tmp = yourClass() tmp.sectionTitle = "someSection" tmp.subData =

我从parse数据库中获得了许多具有以下数据结构的部分。我不知道如何将其设置为数组,并在swift中的repective tableview部分中正确显示它

第一节标题 小分目 小分目 小分目 小分目 第2节标题 小分目 小分目 小分目 小分目
您的数据结构应该是自定义对象的数组(取决于您的值):

从解析中获取数据后,只需循环解析数据并将其添加到数据结构中:

var tmp = yourClass()
tmp.sectionTitle = "someSection"
tmp.subData = ["First subtitle","Second subtitle", "Thirt subtitle"]

yourData.append(tmp)
然后将数据按如下方式排序:

yourData[0].sectionTitle //This is your first section title

yourData[1].sectionTitle //This is your second section title

yourData[0].subData[0] //This is your first subtitle in your first section

等等…

我理解您创建类的理性。但我不知道如何继续,因为我的数据来自解析。我需要做的是为tableview标题和相应单元格的内容调用不同的标题。
var tmp = yourClass()
tmp.sectionTitle = "someSection"
tmp.subData = ["First subtitle","Second subtitle", "Thirt subtitle"]

yourData.append(tmp)
yourData[0].sectionTitle //This is your first section title

yourData[1].sectionTitle //This is your second section title

yourData[0].subData[0] //This is your first subtitle in your first section