title: Swift count non empty instances in struct
body: <p>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 <code>&quot;&quot;</code> when the data no need to be display in the tableView. So I need to count the numberOfRow according to the non <code>&quot;&quot;</code> in the struct. But I have no idea how to do so.</p>
  <p>I need to get the number of row according to non <code>&quot;&quot;</code> in the Post struct below.</p>
  <pre><code>struct Post : Codable {
      let postID : Int?
      let postName : String?
      let postDetail : String?
      let postDesc : String?
  }
  </code></pre>
  <p>I want to get 3 from the JSON data below since the postDesc is <code>&quot;&quot;</code>. How can I count to get the 3.</p>
  <pre><code>{
       &quot;postID&quot;: 325,
       &quot;postName&quot;: &quot;Test1&quot;,
       &quot;postDetail&quot;: &quot;Test1&quot;,
       &quot;postDesc&quot;: &quot;&quot;,
  }
  </code></pre>