Load apps on your iPhone using Xcode 7 (or later version)

https://developer.apple.com/xcode/

“Xcode 7 and Swift now make it easier for everyone to build apps and run them directly on their Apple devices. Simply sign in with your Apple ID, and turn your idea into an app that you can touch on your iPad, iPhone, or Apple Watch. Download Xcode 7 beta and try it yourself today. Program membership is not required.”

  1. Update OS X 10.10.5 (Yosemite) or later version
  2. Download and Install Xcode 7 or later version
  3. Open Xcode, open Preferences and login to your Account
  4. Open the workspace/project in Xcode and build & run on the simulator
  5. Plug in your iPhone and select it as the build Destination

Device

6. Make sure to set iOS Deployment Target (e.g. iOS 8.4) in Build Settings for both Project and Target

Project

Target

7.  Click on the Fix Issue for Failed to code sign xxxx

2015-09-02 20.50.25

8. If there’s no build errors, the app should now launch on your phone

SimpleGeometryCalculator

GeometryCalculator

GeometryCalculator

 

class ViewController: UIViewController, UITextFieldDelegate {

var selectedIndex : Int = 1

@IBOutlet weak var labal6 : UILabel! // geometry type
@IBOutlet weak var labal1 : UILabel! // input1 label
@IBOutlet weak var labal2 : UILabel! // input2 label
@IBOutlet weak var labal3 : UILabel! // input3 label

@IBOutlet weak var textField1 : UITextField! // input1
@IBOutlet weak var textField2 : UITextField! // input2
@IBOutlet weak var textField3 : UITextField! // input3
@IBOutlet weak var textField4 : UITextField! // S.A.
@IBOutlet weak var textField5 : UITextField! // Volume

@IBOutlet weak var selector : UISegmentedControl!

func calculateGeometry() {
if let type = GeometryType.valueOf(selectedIndex) {
label6.text = type.description

// label & textfield
textField1.hidden = false
textField2.hidden = false
textField3.hidden = false
switch type {
case .Sphere:
label1.text = “Radius”
label2.text = “”
label3.text = “”
textField2.hidden = true
textField3.hidden = true
let calc = Sphere(radius: textField1.text!.toDouble())
textField4.text = “\(calc.SurfaceArea)”
textField5.text = “\(calc.Volume)”
case .Cone:
label1.text = “Radius”
label2.text = “Height”
label3.text = “”
textField3.hidden = true
let calc = Cone(radius: textField1.text!.toDouble(), height: textField2.text!.toDouble())
textField4.text = “\(calc.SurfaceArea)”
textField5.text = “\(calc.Volume)”
case .Cylinder:
label1.text = “Radius”
label2.text = “Height”
label3.text = “”
textField3.hidden = true
let calc = Cylinder(radius: textField1.text!.toDouble(), height: textField2.text!.toDouble())
textField4.text = “\(calc.SurfaceArea)”
textField5.text = “\(calc.Volume)”
case .RectangularPrism:
label1.text = “Width”
label2.text = “Height”
label3.text = “Length”
let calc = RectangularPrism(width: textField1.text!.toDouble(), height: textField2.text!.toDouble(), length: textField3.text!.toDouble())
textField4.text = “\(calc.SurfaceArea)”
textField5.text = “\(calc.Volume)”
case .SquarePyramid:
label1.text = “Base”
label2.text = “Height”
label3.text = “”
textField3.hidden = true
let calc = SquarePyramid(base: textField1.text!.toDouble(), height: textField2.text!.toDouble())
textField4.text = “\(calc.SurfaceArea)”
textField5.text = “\(calc.Volume)”
case .IsoscelesTriangularPrism:
label1.text = “Base”
label2.text = “Height”
label3.text = “Length”
let calc = IsoscelesTriangularPrism(base: textField1.text!.toDouble(), height: textField2.text!.toDouble(), length: textField3.text!.toDouble())
textField4.text = “\(calc.SurfaceArea)”
textField5.text = “\(calc.Volume)”
}
}
}

@IBAction func selectGeometry(sender: AnyObject) {
selectedIndex = selector.selectedSegmentIndex + 1
calculateGeometry()
}

func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
calculateGeometry()
return true
}

override func viewDidLoad() {
super.viewDidLoad()
// do something
calculateGeometry()
textField1.delegate = self
textField2.delegate = self
textField3.delegate = self
}

}

SimpleTemperatureConverter

//
//  ViewController.swift
//  SimpleTemperatureConverter
//
//  Created by Kyoung Shin Park on 10/2/16.
//  Copyright © 2016 Kyoung Shin Park. All rights reserved.
//

import UIKit

extension String {
func toDouble() -> Double {
if let unwrappedNum = Double(self) {
return unwrappedNum
}
else {
print(“Error converting \”” + self + “\” to Double”)
return 0.0
}
}
func toInt() -> Int {
if let unwrappedNum = Int(self) {
return unwrappedNum
}
else {
print(“Error converting \”” + self + “\” to Int”)
return 0
}
}
}

class ViewController: UIViewController {

//var fahrenheit : Double = 0.0
//var celsius : Double = 0.0

@IBOutlet weak var fahrenheitTextfield: UITextField!
@IBOutlet weak var celsiusTextfield: UITextField!

@IBAction func convertFahrenheitToCelsius(sender: AnyObject) {
if let _ = sender as? UIButton {
let fahrenheit = fahrenheitTextfield.text!.toDouble()
let converter = FahrenheitToCelsius(temperature: fahrenheit)
celsius = converter.celsius
//celsiusTextfield.text = “\(celsius)”
celsiusTextfield.text = String.localizedStringWithFormat(“%.2f”, celsius)
}
}

@IBAction func convertCelsiusToFahrenheit(sender: AnyObject) {
if let _ = sender as? UIButton {
celsius = celsiusTextfield.text!.toDouble()
let converter = CelsiusToFahrenheit(temperature: celsius)
fahrenheit = converter.fahrenheit
//fahrenheitTextfield.text = “\(fahrenheit)”
fahrenheitTextfield.text = String.localizedStringWithFormat(“%.2f”, fahrenheit)
}
}

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
fahrenheit = 50.0
fahrenheitTextfield.text = “\(fahrenheit)”
celsiusTextfield.text = “”
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

Body Mass Index

BodyMassIndex 방식의  표준체중 (StandardWeightCalculator) 및 일일 칼로리 섭취량 계산기

BMI

BMI (MVC)

(1) 사용자에게 키(Height), 몸무게(Weight), 성별(Male/Female), 나이(Age), 활동량(Low/Medium/High)를 입력 받는다. 입력받는 키의 단위는 cm이고, 몸무게의 단위는 kg이다.
(2) 성별(Gender)에 따라서 표준체중값(Standard Weight)을 화면에 출력한다.
Male: StandardWeight = Height * Height * 22 * 0.0001
Female: StandardWeight = Height * Height * 21 * 0.0001
(3) BMI지수를 다음 공식으로 계산하고 결과를 화면에 출력한다.
BMI = Weight / (Height * Height * 0.0001)
(4) 다음 기준에 따라 BMI를 판단해서 화면에 출력한다.
BMI >= 29 => Obesity
24 <= BMI < 29 => Overweight
20 <= BMI < 24 => Normal
BMI < 20 => Underweight
(5) 다음 공식으로 일일 칼로리 섭취량 (Daily Calory Intake)을 화면에 출력한다.
Low: ActivityCalory = 1.3
Medium: ActivityCalory = 1.5
High: ActivityCalory = 1.75

Male: DailyCaloryIntake = (66.47 + (13.75 * Weight) + (5.0 * Height) – (6.76 * Age)) * AcitivityCalory
Female: DailyCaloryIntake = (655.1 + (9.05 * Weight) + (1.85 * Height) – (4.86 * Age) * AcitivityCalory

AridityIndex

AridityIndex

AridityIndex (VC)

AridityIndexCalculator (MVC)

(1) 사용자에게 연강수량(Precipitation)과 연평균기온(Temperature)를 입력 받는다. 연강수량의 단위는 mm이고, 연평균기온의 단위는 C(섭씨)이다.
(2) 건조지수를 다음 공식으로 계산하고 결과를 화면에 출력한다.
건조지수 AI = Precipitation/ (Temperature + 10)
(3) 다음 기준에 따라 기후의 상태를 판단해서 화면에 출력한다.
AI >= 60 => Perhumid
30 <= AI < 60 => Humid
20 <= AI < 30 => SubHumid
15 <= AI < 20 => SemiArid
5 <= AI < 15 => Arid
AI < 5 => ExtremelyArid

My First iOS App

MyFirst iOS App Hello World

https://s3.amazonaws.com/swiftbook/hello-world-swift.pdf

HelloWorld -label & button & UIAlertController & autolayout

//

//  ViewController.swift

//  HelloWorld

//  Copyright © 2015 Park. All rights reserved.

//

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var label1: UILabel!

 

@IBAction func showMessage(sender: AnyObject) {

label1.text = “Welcome to Swift”

let alertController = UIAlertController(title: “Welcome to my first iOS App”, message: “Hello World”, preferredStyle: UIAlertControllerStyle.Alert)

alertController.addAction(UIAlertAction(title: “OK”, style: UIAlertActionStyle.Default, handler: nil))

self.presentViewController(alertController, animated: true, completion: nil)

}

 

override func viewDidLoad() {

super.viewDidLoad()

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

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

}