I trying to count the number of non empty string in a struct to set the numberOfRow in the tableView. Some of data will return me ""
when the data no need to be display in the tableView. So I need to count the numberOfRow according to the non ""
in the struct. But I have no idea how to do so.
I need to get the number of row according to non ""
in the Post struct below.
struct Post : Codable {
let postID : Int?
let postName : String?
let postDetail : String?
let postDesc : String?
}
I want to get 3 from the JSON data below since the postDesc is ""
. How can I count to get the 3.
{
"postID": 325,
"postName": "Test1",
"postDetail": "Test1",
"postDesc": "",
}