Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Swift. Trying to convert decimal to fraction. Can NumberFormatter (https://developer.apple.com/documentation/foundation/numberformatter) help me convert decimal to fraction? If so can you help me convert with my

Swift. Trying to convert decimal to fraction. Can NumberFormatter (https://developer.apple.com/documentation/foundation/numberformatter) help me convert decimal to fraction? If so can you help me convert with my sample code? If not what are my other options?

var maximumFractionDigits: Int { get set }

===============code==============================

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var textF: UITextField!

@IBOutlet weak var answer: UILabel!

override func viewDidLoad() {

super.viewDidLoad()

// Do any additional setup after loading the view, typically from a nib.

}

@IBAction func enter(_ sender: Any) {

Double(textF.text!) == nil

var guessNumber = Double(textF.text!);

var maximumFractionDigits = guessNumber //not declare correctly open to sugguestion

answer.text = "\(guessNumber!) "

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+17.14. 1 Extend the ideas in the preceding two problems to R *.

Answered: 1 week ago