I want to create ,multidimensional array
in swift with multiple inner arrays
. I want the structure look like this but getting error
while creating this. Please guide me how can I create this structure.
我想用多个内部数组快速创建多维数组。我希望这个结构看起来像这样,但在创建它时出错。请指导我如何创建这个结构。
class ViewController: UIViewController
{
var data2:[String] = []
var LocationPickerData = ["Mozzarella","Gorgonzola","Provolone","Brie","Maytag Blue"]
var LocationPickerData2 = ["Sharp Cheddar","Monterrey Jack","Stilton","Gouda","Goat Cheese", "Asiago"]
var LocationPickerData3 = ["Goat Cheese", "Asiago"]
var Title = ["twwwitle1","sdfsaf","Prsdfasovosdfasflone","sfsa","sdfsf Blue"]
var Title2 = ["seeefdasf Cheddar","sdfsf Jack","fsaf","Gouda","fasf Cheese", "sdfsf"]
var Title3 = ["ddddsdfs ff", "fasfsdffasf"]
var Name = ["fsdfa","fasfsafsf","Provolone","Brie","Maytag Blue"]
var Name2 = ["afsadff Cheddar","Monterrey Jack","Stilton","Gouda","Goat Cheese", "Asiago"]
var Name3 = ["fffffff ffff", "jjjjjjj"]
var data2 = [
location[
location1[ LocationPickerData ],
location2[ LocationPickerData2],
location3[ LocationPickerData3]
],
titles[
title1[Title],
title2[Title2],
title3[Title3]
],
names[
name1[Name],
name2[Name2],
name3[Name3]
]
]
}
1 个解决方案
#1
0
Declare your multidimensional array like this:
声明您的多维数组如下:
var data2 = [
[
LocationPickerData
LocationPickerData2,
LocationPickerData3,
],
[
Title
Title2,
Title3,
],
[
Name
Name2,
Name3,
]
]
Or you can declare a dictionary:
或者你可以声明一本字典:
var data2 = [
"Locations": [
LocationPickerData
LocationPickerData2,
LocationPickerData3,
],
"Titles": [
Title
Title2,
Title3,
],
"Names": [
Name
Name2,
Name3,
]
]
#1
0
Declare your multidimensional array like this:
声明您的多维数组如下:
var data2 = [
[
LocationPickerData
LocationPickerData2,
LocationPickerData3,
],
[
Title
Title2,
Title3,
],
[
Name
Name2,
Name3,
]
]
Or you can declare a dictionary:
或者你可以声明一本字典:
var data2 = [
"Locations": [
LocationPickerData
LocationPickerData2,
LocationPickerData3,
],
"Titles": [
Title
Title2,
Title3,
],
"Names": [
Name
Name2,
Name3,
]
]