Swift Programming Language Tutorial : App – Temperature Conversion : Ideal for beginners

Learn how to build apps : We are going to build an App. A practical, fun and simple App. No programming background needed. You will design, code and test using Xcode , Apple’s IDE. Swift Programming Language Tutorial : App – Temperature Conversion : Ideal for beginners

References for Video:

//generic
http://blog.teamtreehouse.com/should-i-learn-swift
https://medium.com/backchannel/my-computer-language-is-better-than-yours-58d9c9523644
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/

//specific
https://www.youtube.com/watch?v=H83CpUMIoxA
http://stackoverflow.com/questions/24871532/xcode-ios-8-keyboard-types-not-supported
http://www.quora.com/Xcode/What-is-the-significance-of-a-projects-organization-identifier

Script:
=======

Hello People
In this video we will develop a simple and useful app that does temperature conversion calculations.
As you guys know, there are 2 popular temperature scales: Fahrenheit, named after the German-Dutch physicist Daniel 
Gabriel Fahrenheit AND Celsius, named after the Swedish astronomer Anders Celsius.

Now most countries have adopted Celsius as their temperature scale. However some like the Bahamas, Cayman Islands and the Unit
ed States continue to use the Fahrenheit.
And because of this, many a time, we need to convert from one scale to another.

So our app will look something like this.
It will allow the user to enter a temperature in Celsius and on clicking a button, convert it to Fahrenheit.

Am going to keep this app very simple since the objective is to give you a quick tour of App creation in SWIFT.

We will learn how to design the look of our app by adding labels, text fields, buttons Etc.
We will also learn how to attach these elements to code. 
Code that will help us do something useful like convert a temperature, as in this case.

Ok, you have seen the end result. But what do you need to start?

Well You need a computer running Xcode, Apple’s Integrated Development environment or IDE.
This is what is needed to create our App.

And yes, you need a good bit of inquisitiveness. That will be smashing.
And no, you do not need a background in Programming.

So the first thing we will do is write the pseudocode and then code of our application.
And for this lets head over to the playground.

Playground:
============

import UIKit

// get user input: c
var celsius:Int = 10

//formula : c to f
// 5f = 9c + 160

//output : f
var fah:Int = ( 9 * celsius + 160 ) / 5

println(fah)

Tools Used:
============

Microphone : Samson Meteor + Blue Yeti
Voice Editor : Audacity
Animation : Sparkol Video scribe
Illustrations: funza Academy + openclipart.org
Video editor + SFX : iMovie + ScreenFlow
Pop Filter : A Clean Sock !
Computer : MacBook Air

Individuals involved in Video:
Sanjay Noronha, Preeti Kaul

Comments

Lanka Videos says:

this works well for men( swift 2.0 ) try it out

@IBOutlet weak var celvalue: UITextField!

@IBOutlet weak var fahvalue: UILabel!

// The action for the button

@IBAction func calculate(sender: AnyObject) {

if celvalue.text == “” {

// print error massage into the label text
fahvalue.text = “you haven’t entered a value”

} else {

// Converting text box value(string) to integer
let cel:Double = Double(celvalue.text!)!

// The Formula
let fah:Double = (9 * cel + 160 ) / 5

// print the value into the label text
fahvalue.text = “Celsius (cel) is (fah) fahrenheit”

}

}

J Darcy says:

I am just learning Swift and Playground. I am a prehistoric programmer – COBOL, Autocoder, SPS. I am using Playground to quickly develop code, then in Swift I copy/paste all of the Playground code into the Swift project. Is this the way to use these two languages: quick code then copy/paste – OR – is there a way to call Playground code from within Swift?

Thanks for reading this. I really like what you are doing. Keep up the good work.

kukuyeah says:

This is a great tutorial. Thank you, it’s very helpful.

DC Antonella says:

Thank you !!

SkiNNy says:

bro just use if to only run code if variable is != null

J Darcy says:

I really appreciate what you have done. Thank you so much.
I am running Xcode 7.2, Swift 2.3 (latest versions).
I am having a problem with getting the Fahrenheit value to display on the layout. It works fine in Playground and in the Debug area – but not on the screen display.

Code(with various attempts commented out):
_________________________________________________________________
@IBAction func Calculate(sender: AnyObject)
{
var celsius = 0
// let celsius:String? = celsiusValue.text
celsius = Int(celsiusValue)!
// var celsiusValue = Int(celsiusValue)!
// if let celsiusunit = Int(celsius!)
var fah:Int = (9 * celsius + 160) / 5;
// fah.text = “(celsius) is (celsius)”
print (“Celsius = (celsius), Farenheit = (fah)”)
}
________________________________________________________________
Thank you for reviewing this

Alexa Ramirez says:

this helped so much!

Phiraphon Siriputtaiwon says:

This is an incredibly useful tutorial video. It does help visualising on how Swift codes are associated with Xcode. As an absolute beginner like myself, I thank you heaps for doing this. Oh and I will definitely check out your other tutorials as well :) Keep up the good work!!

tantri arya says:

I made a post about the swift ebook that you can download for free http://tinyurl.com/pmzx39h

Mujtaba Alhaddad says:

i can’t find printIn on Xcode version 7.x.x
can please someone please help

thanks a lot

Simon McNamara says:

As soon as i enter the value println it says error c99 and that it is not recognized my only option is to write printf and the does not seem to work when i press calculate for some reason

Kieron Atkinson says:

doesnt even work man for man norman

Jon Doe says:

What was the thumbnail about? I wanted to know what it was, but I am already committed to another 3 hour video.

Freddy Manzanares says:

I have a problem, i am using xcode 7 and whenever i try to use:

var celcius:Int = celciusValue.text.toInt()!

the las part of “toInt” makes me an error it says:

“Value of optional type ‘String?’ not unwrapped; do you mean to use ‘!’ or ‘?’?'”

what can i do??

kameshayachit says:

Hi Sanjay,
Whenever we pull out an IBAction event for any button its type changes to AnyObject by default. Should we not change it to UIButton before referencing the button to view controller? I can see you don’t change it still app behaves as expected. What are the various factors we need to consider before choosing between any of the options?

Markdby time says:

Thank you funza Academy for making this invaluable video. It was super helpful to see how the Standard Editor and Assistant Editor are used in combination with each other. Keep the videos coming!

J Darcy says:

I finished the ‘Fahrenheit to Celsius’ program. It runs on the Mac. I have an Ipad Air 2. How do I transfer this App on my Mac to the Ipad?

ricotheweddingsinger says:

Keep on creating great swift videos. Your video is very easy to follow. I find it very useful and fun. Thank you. Thank you so much :)

Ruud Faessen says:

this voice :)

Michael Phillips says:

I’m stuck on this, I have gotten up to 23.33 but I have a couple of errors now, they stop me from running the app.

The bit of code that has the errors is below 

var celsius:Int = celsiusValue.text.toInt()!

This is what I’ve got in the code, I have two errors on this…

“String” does not have a member named “Int”

Value of optional type “string?” not unwrapped, did you mean to use “?” or “!” ?

Mujahid ur Rehman says:

well done Funza team. keep them coming…

abbas annooz says:

Thank you very much . Really I like your way in tutorial so PRO

Manoz Chain says:

thanks for your tutorial ….
@IBAction func ConversionButton(_ sender: Any)
{
let temperatureInDegreeCentigrade = Double(centigradeTextField.text!)!
let myFahrenheit = (temperatureInDegreeCentigrade * 9/5) + 32
label.text = “(myFahrenheit) degree Fahrenheit”

}

James Rule says:

These simple apps are great for understanding the basics, really have helped. Thank you!

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours