How to change the UITextfield text with data from JSON based on the value from UISlider in Swift 4?

How to change the UITextfield text with data from JSON based on the value from UISlider in Swift 4?

Right now I have the UIText field hard coded and changing according to the value on the UISlider.

Right now I have the UIText field hard coded and changing according to the value on the UISlider.

    @IBAction func sliderValueChanged(_ sender: UISlider) {

let currentValue = Int(sender.value)

levelLabel.text = "Food Level \(currentValue)"


if currentValue == 1 {


    foodDescription.text = "Healthy Vegetables: (raw, steamed, roasted, frozen). "

I was able to connect to the REST api and get the JSON results parsed.

Now, the slider has values from 1 to 6.

The JSON is structured like this:

{
   "Level1": "3",
   "LevelCategory": "This includes all meats, seafood and poultry. We recommend organic sources here. Eggs (with and without yolk) are also in this section.",
   "LevelID": "1275a833-b250-4de0-b29a-0b926e57bff0",
   "LevelName": "Proteins"
}

What's the best way to check the slider value and get the correct Level Category, Name etc. using the JSON data?

Right now, I'm using IF for the slider value. Is there a better way to do this?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

What is JSON - JSON Parsing in Swift

What is JSON and how do you parse JSON in Swift? JSON stands for JavaScript Object Notation and it's a way to represent data in a standard way. Learn how to parse JSON in Swift using the Codable protocol. We take the response JSON data from a real API call and then parse it in Swift!

How To Build Reminders iOS App in Swift 5 for Beginners

In this video, we build the Reminders App in Swift for iOS. Learn how to use dates, local / user notifications, tableviews, and much more. From scratch to working app, we'll go over every step up toe process together.

iOS App Development: How Apple's iOS 13 & Swift 5 Will Change App Development Industry

Want to know how Apple's iOS 13 & Swift 5 will change the iOS app development industry? Refer to this blog that contains in-detail information on it.