1
When the result comes from the server I use the following code snippet to receive the result:
if let JSON = response.result.value {
print("JSON: \(JSON)")
}
And the result of the print is:
[{
Nome = Tiago;
Idade = 22;
Cidade = Minas;
}, {
Nome = Luisa;
Idade = 12;
Cidade = Califórnia;
}]
How can I take this result and place it in an array?
Where do you get this JSON? since you have not declared it?
– HideCode
@Hidecode How you put the tag Alamofire put an example of the request, if you want to test it just add one
let url = 'caminhoDaRequisicao'
the content that solves your doubt is the array statement and how the json result is inserted into the array within the for– Gabriel Rodrigues
I tried to do a for to access the information that is inside the text but does not show me anything. I did it like this
for pessoas in self.texto{
 print(pessoas)
 }
– HideCode
the problem here I think is that I am receiving an array with arrays inside. I tried to do this
let json = JSON(value)
 for (_, subJson) in json {
 self.texto.append(subJson.stringValue) // Inserindo valores no array
 print(self.texto)
 }
and the result I got was "", "" "", "" "" "", "" "" "" ""– HideCode
you are using ? https://github.com/SwiftyJSON/SwiftyJSON
– Gabriel Rodrigues
I am, but for example if I want to do this
let listresultados: Array<JSON> = json["list"].arrayValue
 
 for number in listresultados {
 print(number)
 }
I can’t because in the result that comes from the server where is actually "list" I have "", hence I am not able to fetch the data you see– HideCode
I got the solution and it was the following
Alamofire.request(mutableURLRequest)
 .responseJSON{
 response in
 if let value: AnyObject = response.result.value {

 let json = JSON(value)
 print(json)
 for (_, subJson) in json {
 self.texto.addObject(subJson.object)
 }
 }
 }

– HideCode
@Hidecode Oce only switched to addObject ? the append should work. I edited answer to help someone who may have the same doubt.
– Gabriel Rodrigues