i'm trying to get response in my model object, but facing an issue that it is showing me only first item of response, this is my code,
func getUserBalanceAPI()
{
APIService.getUserBalance{ (responseObject) in
if (responseObject?.status)! {
self.balanceArray.removeAll()
let user = UserCompleteBalance(JSON: (responseObject?.data as! [[String : Any]]).first!)
self.balanceArray.append(user!)
//Reload Collection View
self.currencyCVC.reloadData()
}
else if !(responseObject?.status)! {
Utilities.showBar(text: responseObject?.errorObject?.message)
}
}
}
How can i get all the items in an array? This is my response,
"responseBody": {
"data": [
{
"auction_deposit": 4083.63,
"currencyCode": "USD",
"userCurrencyId": 1,
"availableBalance": 64555.1,
"currentBalance": 68638.73
},
{
"auction_deposit": 0.0,
"currencyCode": "AED",
"userCurrencyId": 2,
"availableBalance": 198000.0,
"currentBalance": 198000.0
},
{
"auction_deposit": 0.0,
"currencyCode": "EUR",
"userCurrencyId": 3,
"availableBalance": 50000.0,
"currentBalance": 50000.0
}
]
}
This is my model class,
class UserCompleteBalance : Mappable {
var auctionDeposit : Int?
var availableBalance : Int?
var currencyCode : Int?
var currentBalance : Int?
var userCurrencyId : Int?
required init?(map: Map) {
}
func mapping(map: Map) {
auctionDeposit <- map["auction_deposit"]
currencyCode <- map["currencyCode"]
userCurrencyId <- map["userCurrencyId"]
availableBalance <- map["availableBalance"]
currentBalance <- map["currentBalance"]
}
}
Now i want to store all the response in this.