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

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift