I've created a multidimensinal array which is suppose to hold different sections of news for instance popular and Recent news. i've therefore created a array like this where News is my class.
var arrayNews = Array<Array<News>>()
After this i'm looping through my first JSON file like this
for (key: String, subJson: JSON) in jsonArray {
// Create an object and parse your JSON one by one to append it to your array
var newNewsObject = News(id: subJson["id"].intValue, title: subJson["title"].stringValue, link: subJson["url"].stringValue, imageLink: subJson["image_url"].stringValue, summary: subJson["news_text"].stringValue, date: subJson["date"].stringValue)
arrayNews.append(newNewsObject)
}
However i'm getting following error when i try to append it to the array?
cannot invoke append with an argument list of type (News)
Testing answer
var arrayNews = Array<Array<News>>()
let recentArray = [News]()
for (key: String, subJson: JSON) in jsonArray {
// Create an object and parse your JSON one by one to append it to your array
var newNewsObject = News(id: subJson["id"].intValue, title: subJson["title"].stringValue, link: subJson["url"].stringValue, imageLink: subJson["image_url"].stringValue, summary: subJson["news_text"].stringValue, date: subJson["date"].stringValue)
recentArray.append(newNewsObject)
}
arrayNews.append(recentArray)
error message
immutable value of '[(News)] only has mutating members named append