I get String from api response and stored in an array.
for customParams in custom_attributes! {
if(customParams[\"attribute_code\"] as! String == \
var myArray :[String] = []
for customParams in custom_attributes! {
if(customParams["attribute_code"] as! String == "small_image") {
var myString = customParams["value"] as! String
myArray.append(myString)
}
}
You need to loop through the items array first as it is in json, also declare myArray outside the for loop and start appending myString inside myArray as shown:
var myArray :[String] = []
for custom_attributes! in items { // items is the json items array
for customParams in custom_attributes! {
if(customParams["attribute_code"] as! String == "small_image")
{
print(customParams["value"])
var myString = customParams["value"] as! String
myArray.append(myString)
}
}
}