Search code examples
swiftbuttonibactioniboutlet

expression resolves to an unused I-value during if statement


So I'm downloading a String from CloudKit, created here

let facebookurl = detail.value(forKey: "Facebook") as? String

I also have an outlet saved as facebookbutton and an action button set as Facebook.

I want to have my code set up as such that if facebookurl is empty "", the facebookbutton hides the actual button facebook, like such.

 if facebookurl == ""
    {
        facebookbutton.isHidden
    }

However, Xcode reverts me to the unused I-value error. What seems to be amish here?


Solution

  • You're setting the isHidden property for your button, but you're never assigning a value. You need to complete the process by setting the isHidden a value of either true or false:

    if facebookurl == "" {
    
        facebookbutton.isHidden = true
    
    }