<file_sep>//
//  ViewController.swift
//  CurrencyConversionExample
//
//  Created by <NAME> on 7/7/19.
//  Copyright © 2019 <NAME>. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var displayLabel: UILabel!
    @IBOutlet weak var entryField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    
    @IBAction func convertButton(_ sender: UIButton) {
        let numericValue = Int(entryField.text!)!
        let currencyConversion = convertIntToCurrencyAsString(intValue: numericValue)
        displayLabel.text = currencyConversion
    }
    
    
    func convertIntToCurrencyAsString(intValue: Int) -> String {
        var stringVersion: String
        let cFormatter = NumberFormatter()
        cFormatter.usesGroupingSeparator = true
        cFormatter.numberStyle = .currency
        if let currencyString = cFormatter.string(from: NSNumber(value: intValue)) {
            stringVersion = currencyString
        } else {
            stringVersion = "Invalid Message"
        }
        return stringVersion
    }


}

<file_sep># Swift to Int to Currency Converter Example

This is an example of converting an entered string to an integer and then currency in response to a Reddit question.
You can find the question on [Reddit here](https://www.reddit.com/r/iOSProgramming/comments/c5ttl6/new_to_swift_trying_to_make_a_simple_app_to_count/)

Enter a value in the text field and hit the convert button. This calls a function that will perform the conversation and return a string to be used for display.
