How to check the string is Nil or Not and

Solution: The function will return empty string if your variable contains nil value otherwise it will returns its value.

 func noNilString(string: AnyObject?) -> String {

        if let category = string as? String {

            return category

        } else {

            return ""

        }

    }


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift