setting a row height to 0, for selected rows (swift)
<p>In my app, I have "groups" of species displayed on a UITableView.  </p>

<p>Some groups are free and some are in-App purchase.</p>

<p>The groups that are an in-app purchase have a UIImage of a padlock on that row set up in the <code>cellForRowAtIndexPath</code>.</p>

<pre><code>    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell
    {
        let cell: UITableViewCell       = tableView.dequeueReusableCell(withIdentifier: Resource.SpeciesCell)!

        let specieImage: UIImageView    = cell.viewWithTag(Resource.SpeciesImageTag) as! UIImageView
        let specieName: UILabel         = cell.viewWithTag(Resource.SpeciesNameTag) as! UILabel
        let specieGenus: UILabel        = cell.viewWithTag(Resource.SpeciesGenusTag) as! UILabel
        let specieFamily: UILabel       = cell.viewWithTag(Resource.SpeciesFamilyTag) as! UILabel

        specieName.text     = self.species[(indexPath as NSIndexPath).row].specie
        specieFamily.text   = ""
        specieGenus.text    =  AppDelegate.getRLDatabase().getSubGroupName_BySpecieName(specieName.text!)


        let padLock: UIImageView        = cell.viewWithTag(Resource.SpeciesCategoryLabelTag) as! UIImageView

        padLock.image = UIImage(named: "PadlockIcon")
        padLock.alpha = 0.7

        let fishesPurchased = UserDefaults.standard.bool (forKey: "ReefLife5Fishes")
        let sharksPurchased = UserDefaults.standard.bool (forKey: "ReefLife6Sharks")
        let turtlesPurchased = UserDefaults.standard.bool (forKey: "ReefLife8Turtles")
        let seahorsesPurchased = UserDefaults.standard.bool (forKey: "ReefLife9Seahorses")
        let vertebratesPurchased = UserDefaults.standard.bool (forKey: "ReefLife3Vertebrates")
        let fullPurchased = UserDefaults.standard.bool (forKey: "ReefLife1Full")

        padLock.isHidden = false
        specieImage.alpha = 1.0

        let speciesGroup = self.species[(indexPath as NSIndexPath).row].group

        if fullPurchased == true {

            padLock.isHidden = true
            specieImage.alpha = 1.0

        } else if speciesGroupVertebratesArray.contains(speciesGroup) {

            if vertebratesPurchased == true {

                padLock.isHidden = true
                specieImage.alpha = 1.0

            } else {

                if speciesGroup == "Fish" {
                    if fishesPurchased == true{
                        padLock.isHidden = true
                        specieImage.alpha = 1.0

                    } else{
                        specieImage.alpha = 0.5
                    }
                } else if (speciesGroup == "Sharks" || speciesGroup == "Rays" ) {
                    if sharksPurchased == true{
                        padLock.isHidden = true
                        specieImage.alpha = 1.0

                    } else{
                        specieImage.alpha = 0.5
                    }
                } else if speciesGroup == "Syngnathiformes" {
                    if seahorsesPurchased == true{
                        padLock.isHidden = true
                        specieImage.alpha = 1.0

                    } else{
                        specieImage.alpha = 0.5
                    }
                } else if speciesGroup == "Reptilia" {
                    if turtlesPurchased == true{
                        padLock.isHidden = true
                        specieImage.alpha = 1.0

                    } else{
                        specieImage.alpha = 0.5
                    }
                }
            }

        }
 .... 
</code></pre>

<p>I have an option settings to "hide locked items" based on a UISwitch</p>

<p>When the user selects this, I want to hide the locked groups ( or non purchased items).  I figured the best way to achieve this would be to hide the specific rows, by setting the row height to 0.</p>

<p>I am struggling to set the row height to 0 using the indexPath.row as it the indexPath.row does not accept a CGFloat command.</p>

<p>Suggestions?</p>

<p>EDIT:
Realize I need to use the heightForRowAt indexPath: IndexPath function, but I have having a difficult time assigning it to a indexPath.row.</p>

<p>Maybe a better question would be: How can I set it up so that I know which indexPath.row has "padLock.isHidden == false".</p>