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

Fundamental Design Patterns

Fundamental Design Patterns

https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/books/StreamlineYourAppswithDesignPatterns/StreamlineYourApps/StreamlineYourApps.html

 

Use of the Model-View-Controller (MVC) design pattern ensures that the objects you create now can be reused or updated easily in future versions of your application. http://developer.apple.com/library/mac/#documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html#//apple_ref/doc/uid/TP40008195-CH32

 

The delegation design pattern allows you to change the runtime behavior of an object without subclassing. Delegation is a pattern where one object sends messages to another object—specified as its delegate—to ask for input or to notify the it that an event is occurring.
http://developer.apple.com/library/mac/#documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html#//apple_ref/doc/uid/TP40008195-CH14

Controls use the target-action design pattern to notify your application of user interactions. Target-Action is a design pattern in which an object holds the information necessary to send a message to another object when an event occurs.
http://developer.apple.com/library/mac/#documentation/General/Conceptual/Devpedia-CocoaApp/TargetAction.html#//apple_ref/doc/uid/TP40009071-CH3

 

Other Design Patterns
http://developer.apple.com/library/mac/#documentation/General/Conceptual/
MOSXAppProgrammingGuide/CoreAppDesign/CoreAppDesign.html#//
apple_ref/doc/uid/TP40010543-CH3-SW1

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/
CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//
apple_ref/doc/uid/TP40002974-CH6-SW6

The Launch Cycle

https://developer.apple.com/library/prerelease/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StrategiesforHandlingAppStateTransitions/StrategiesforHandlingAppStateTransitions.html

When your app is launched (either into the foreground or background), use your app delegate’s application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods.

At launch time, the system automatically loads your app’s main storyboard file and loads the initial view controller. For apps that support state restoration, the state restoration machinery restores your interface to its previous state between calls to the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods.

 

Guide to Reference

ARC is a compile time feature that is Apple’s version of automated memory management. It stands for Automatic Reference Counting. This means that it only frees up memory for objects when there are zero strong references/ to them.

A guide to reference: when to use Strong reference, Weak reference, Unowned reference, ImplicitlyUnwrappedOptional property

 

Optional

non-Optional

Optional

strong reference &

weak reference 

 strong reference & 

unowned reference

non-Optional

strong reference &

unowned reference 

 unowned reference & 

implicitly unwrapped optional property

Extension

extension String {

func toFloat() -> Float {

if let unwrappedNum = Float(self) {

return unwrappedNum

}

else {

print(“Error converting \”” + self + “\” to Float”)

return 0.0

}

}

}

 

//  Double to String with Format

var text = String.localizedStringWithFormat(“%.2f”, doubleValue)

// String to Float/Double

var floatValue = text.toFloat()