SlideShare a Scribd company logo
1 of 12
Download to read offline
Swift 3 : Data Types
군산대학교 컴퓨터정보통신공학부 컴퓨터정보공학전공
남 광 우
kwnam@kunsan.ac.kr
Swift 3 Tour and Language Guide by Apple
꼼꼼한 재은씨의 Swift 2 프로그래밍
Data Type 개요
• Swift에서 모든 데이터 타입은 객체
• Int , float 등 모든 type이 객체
• C에서의 int는 atomic type
• Java에서는 int Type과 Integer(객체)로 구분 사용
• 그래서..
• 3.distanceTo( 5)    : (O)
• Int.max :  (O)
Simple Values
• 변수와 상수의 선언
• 타입의 추정
var myVariable = 42  // 변수
myVariable = 50
let myConstant = 42 // 상수
let implicitInteger = 70
let implicitDouble = 70.0
let explicitDouble: Double = 70
Simple Values
• 서로 다른 타입 값의 변환
• 변수 상수의 이름은 한글 한자도 가능
let label = "The width is "
let width = 94
let widthLabel = label + String(width)
var 한글변수 = 3
let ㅎㄱㅂㅅ = 5.3
기본 자료형
• Int
• Int8, Int16, Int32, Int64
• Uint
• UInt8, UInt16, UInt32, UInt64
• Double & Float
• Bool
• String
• Character
기본 자료형
• 자료형의 선언과 사용의 세가지 방법
// first
var day = 7
// second
var day : Int
day = 7
//  third
var day : Int = 7
// 다음은 error!!!!
var day 
day = 7
닫힌 범위 연산자
• 범위 값을 나타내는 연산
• 1…5  : 1, 2, 3, 4, 5
• 1..<5 : 1, 2, 3, 4
• for 문에서의 사용
• hello 100번 print 하기
for  i in 1…100
{
print( “Hello” )
}
문자열 template
• 변수, 상수 값을 대입하기 위한 template
•  (이스케이프) 문자의 사용
• hello world  1..<100 까지 번호와 함께 찍기
let apples = 3
let oranges = 5
let appleSummary = "I have (apples) apples."
let fruitSummary = "I have (apples + oranges) pieces of fruit.
Type Aliases
• Type 선언을 할 수 있음
• 객체 메소드 그대로 사용 가능
typealias AudioSample = UInt16
var maxAmplitudeFound = AudioSample.min
// maxAmplitudeFound is now 0
Tuple
• Tuple
• 다수개의 쌍으로 표현되는 데이터 모음 타입
• return 타입으로 사용가능
• 선언
• 사용 예
let http404Error = (404, "Not Found")
// http404Error is of type (Int, String), and 
equals (404, "Not Found")
let (statusCode, statusMessage) = http404Error
print("The status code is (statusCode)")
// Prints "The status code is 404"
print("The status message is (statusMessage)")
// Prints "The status message is Not Found"
Tuple
• Tuple에서의 _
• Tuple에서의 individual element name
let (justTheStatusCode, _) = http404Error
print("The status code is (justTheStatusCode)")
// Prints "The status code is 404"
let http200Status = (statusCode: 200, description: "OK")
print("The status code is (http200Status.statusCode)")
// Prints "The status code is 200“
print("The status message is (http200Status.description)")
// Prints "The status message is OK"
Tuple
• Tuple에서의 Index 사용
let http200Status = (statusCode: 200, description: "OK")
print("The status code is (http404Error.0)")
// Prints "The status code is 404"
print("The status message is (http404Error.1)")
// Prints "The status message is Not Found"

More Related Content

Viewers also liked

Coworkingpoint mataró
Coworkingpoint mataróCoworkingpoint mataró
Coworkingpoint mataróelssuco
 
ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...
ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...
ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...Istanbul Tech Talks
 
Le point sur le Commerce Mobile avec Criteo
Le point sur le Commerce Mobile avec CriteoLe point sur le Commerce Mobile avec Criteo
Le point sur le Commerce Mobile avec CriteoPhilippe Dumont
 
Dailymotion presenting xbox one experience days by damien delaire
Dailymotion presenting xbox one experience days by damien delaireDailymotion presenting xbox one experience days by damien delaire
Dailymotion presenting xbox one experience days by damien delaireDamien Delaire
 
Native Mobile Apps For Everyone
Native Mobile Apps For EveryoneNative Mobile Apps For Everyone
Native Mobile Apps For EveryoneChris Riesgo
 
Driving Enterprise Data Governance for Big Data Systems through Apache Falcon
Driving Enterprise Data Governance for Big Data Systems through Apache FalconDriving Enterprise Data Governance for Big Data Systems through Apache Falcon
Driving Enterprise Data Governance for Big Data Systems through Apache FalconDataWorks Summit
 
Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...
Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...
Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...Osservatorio Multicanalità
 
Swift 3 Programming for iOS : class and structure
Swift 3 Programming for iOS : class and structureSwift 3 Programming for iOS : class and structure
Swift 3 Programming for iOS : class and structureKwang Woo NAM
 
Introduction to Life Skills
Introduction to Life SkillsIntroduction to Life Skills
Introduction to Life SkillsSyed Mohsin Raja
 
codecept.js introduce - front end test E2E tool introduce
codecept.js introduce - front end test E2E tool introducecodecept.js introduce - front end test E2E tool introduce
codecept.js introduce - front end test E2E tool introduceCaesar Chi
 
Hortonworks Big Data Career Paths and Training
Hortonworks Big Data Career Paths and Training Hortonworks Big Data Career Paths and Training
Hortonworks Big Data Career Paths and Training Aengus Rooney
 

Viewers also liked (14)

Coworkingpoint mataró
Coworkingpoint mataróCoworkingpoint mataró
Coworkingpoint mataró
 
ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...
ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...
ITT 2015 - Simon Tennant - Your App Just Got Social: Adding Messaging to Your...
 
Le point sur le Commerce Mobile avec Criteo
Le point sur le Commerce Mobile avec CriteoLe point sur le Commerce Mobile avec Criteo
Le point sur le Commerce Mobile avec Criteo
 
Dailymotion presenting xbox one experience days by damien delaire
Dailymotion presenting xbox one experience days by damien delaireDailymotion presenting xbox one experience days by damien delaire
Dailymotion presenting xbox one experience days by damien delaire
 
Native Mobile Apps For Everyone
Native Mobile Apps For EveryoneNative Mobile Apps For Everyone
Native Mobile Apps For Everyone
 
Driving Enterprise Data Governance for Big Data Systems through Apache Falcon
Driving Enterprise Data Governance for Big Data Systems through Apache FalconDriving Enterprise Data Governance for Big Data Systems through Apache Falcon
Driving Enterprise Data Governance for Big Data Systems through Apache Falcon
 
Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...
Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...
Quale sviluppo per la multicanalità nelle imprese italiane? - Andrea Boaretto...
 
OM15 Politecnico di Milano, Giuliano Noci
OM15 Politecnico di Milano, Giuliano NociOM15 Politecnico di Milano, Giuliano Noci
OM15 Politecnico di Milano, Giuliano Noci
 
Azure and the Modern Datacenter - Azure Networking
Azure and the Modern Datacenter - Azure NetworkingAzure and the Modern Datacenter - Azure Networking
Azure and the Modern Datacenter - Azure Networking
 
Swift 3 Programming for iOS : class and structure
Swift 3 Programming for iOS : class and structureSwift 3 Programming for iOS : class and structure
Swift 3 Programming for iOS : class and structure
 
Introduction to Life Skills
Introduction to Life SkillsIntroduction to Life Skills
Introduction to Life Skills
 
codecept.js introduce - front end test E2E tool introduce
codecept.js introduce - front end test E2E tool introducecodecept.js introduce - front end test E2E tool introduce
codecept.js introduce - front end test E2E tool introduce
 
Hortonworks Big Data Career Paths and Training
Hortonworks Big Data Career Paths and Training Hortonworks Big Data Career Paths and Training
Hortonworks Big Data Career Paths and Training
 
Контекстная реклама от Zebra Telecom
Контекстная реклама от Zebra TelecomКонтекстная реклама от Zebra Telecom
Контекстная реклама от Zebra Telecom
 

More from Kwang Woo NAM

메타버스시대의_디지털트윈과_지역성v01.pdf
메타버스시대의_디지털트윈과_지역성v01.pdf메타버스시대의_디지털트윈과_지역성v01.pdf
메타버스시대의_디지털트윈과_지역성v01.pdfKwang Woo NAM
 
해양디지털트윈v02.pdf
해양디지털트윈v02.pdf해양디지털트윈v02.pdf
해양디지털트윈v02.pdfKwang Woo NAM
 
Moving objects media data computing(2019)
Moving objects media data computing(2019)Moving objects media data computing(2019)
Moving objects media data computing(2019)Kwang Woo NAM
 
Moving Objects and Spatial Data Computing
Moving Objects and Spatial Data ComputingMoving Objects and Spatial Data Computing
Moving Objects and Spatial Data ComputingKwang Woo NAM
 
세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석
세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석
세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석Kwang Woo NAM
 
[공간정보시스템 개론] L04 항공사진의 이해
[공간정보시스템 개론] L04 항공사진의 이해[공간정보시스템 개론] L04 항공사진의 이해
[공간정보시스템 개론] L04 항공사진의 이해Kwang Woo NAM
 
[공간정보시스템 개론] L03 지구의형상과좌표체계
[공간정보시스템 개론] L03 지구의형상과좌표체계[공간정보시스템 개론] L03 지구의형상과좌표체계
[공간정보시스템 개론] L03 지구의형상과좌표체계Kwang Woo NAM
 
[공간정보시스템 개론] L02 공간정보와 지리정보
[공간정보시스템 개론] L02 공간정보와 지리정보[공간정보시스템 개론] L02 공간정보와 지리정보
[공간정보시스템 개론] L02 공간정보와 지리정보Kwang Woo NAM
 
[공간정보시스템 개론] L01 공간정보시스템개요
[공간정보시스템 개론] L01 공간정보시스템개요[공간정보시스템 개론] L01 공간정보시스템개요
[공간정보시스템 개론] L01 공간정보시스템개요Kwang Woo NAM
 
[공간정보시스템 개론] L12 공간정보분석
[공간정보시스템 개론] L12 공간정보분석[공간정보시스템 개론] L12 공간정보분석
[공간정보시스템 개론] L12 공간정보분석Kwang Woo NAM
 
[공간정보시스템 개론] L11 공간정보의 구축
[공간정보시스템 개론] L11 공간정보의 구축[공간정보시스템 개론] L11 공간정보의 구축
[공간정보시스템 개론] L11 공간정보의 구축Kwang Woo NAM
 
[공간정보시스템 개론] L10 수치표고모델
[공간정보시스템 개론] L10 수치표고모델[공간정보시스템 개론] L10 수치표고모델
[공간정보시스템 개론] L10 수치표고모델Kwang Woo NAM
 
[공간정보시스템 개론] L09 공간 데이터 모델
[공간정보시스템 개론] L09 공간 데이터 모델[공간정보시스템 개론] L09 공간 데이터 모델
[공간정보시스템 개론] L09 공간 데이터 모델Kwang Woo NAM
 
[공간정보시스템 개론] L08 gnss의 개념과 활용
[공간정보시스템 개론] L08 gnss의 개념과 활용[공간정보시스템 개론] L08 gnss의 개념과 활용
[공간정보시스템 개론] L08 gnss의 개념과 활용Kwang Woo NAM
 
[공간정보시스템 개론] L07 원격탐사의 개념과 활용
[공간정보시스템 개론] L07 원격탐사의 개념과 활용[공간정보시스템 개론] L07 원격탐사의 개념과 활용
[공간정보시스템 개론] L07 원격탐사의 개념과 활용Kwang Woo NAM
 
[공간정보시스템 개론] L06 GIS의 이해
[공간정보시스템 개론] L06 GIS의 이해[공간정보시스템 개론] L06 GIS의 이해
[공간정보시스템 개론] L06 GIS의 이해Kwang Woo NAM
 
[공간정보시스템 개론] L05 우리나라의 수치지도
[공간정보시스템 개론] L05 우리나라의 수치지도[공간정보시스템 개론] L05 우리나라의 수치지도
[공간정보시스템 개론] L05 우리나라의 수치지도Kwang Woo NAM
 
Swift 3 Programming for iOS : Protocol
Swift 3 Programming for iOS : ProtocolSwift 3 Programming for iOS : Protocol
Swift 3 Programming for iOS : ProtocolKwang Woo NAM
 
Swift 3 Programming for iOS : extension
Swift 3 Programming for iOS : extensionSwift 3 Programming for iOS : extension
Swift 3 Programming for iOS : extensionKwang Woo NAM
 
Swift 3 Programming for iOS : Enumeration
Swift 3 Programming for iOS : EnumerationSwift 3 Programming for iOS : Enumeration
Swift 3 Programming for iOS : EnumerationKwang Woo NAM
 

More from Kwang Woo NAM (20)

메타버스시대의_디지털트윈과_지역성v01.pdf
메타버스시대의_디지털트윈과_지역성v01.pdf메타버스시대의_디지털트윈과_지역성v01.pdf
메타버스시대의_디지털트윈과_지역성v01.pdf
 
해양디지털트윈v02.pdf
해양디지털트윈v02.pdf해양디지털트윈v02.pdf
해양디지털트윈v02.pdf
 
Moving objects media data computing(2019)
Moving objects media data computing(2019)Moving objects media data computing(2019)
Moving objects media data computing(2019)
 
Moving Objects and Spatial Data Computing
Moving Objects and Spatial Data ComputingMoving Objects and Spatial Data Computing
Moving Objects and Spatial Data Computing
 
세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석
세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석
세월호/ 타이타닉호 사고의 빅 데이터 방법론적 분석
 
[공간정보시스템 개론] L04 항공사진의 이해
[공간정보시스템 개론] L04 항공사진의 이해[공간정보시스템 개론] L04 항공사진의 이해
[공간정보시스템 개론] L04 항공사진의 이해
 
[공간정보시스템 개론] L03 지구의형상과좌표체계
[공간정보시스템 개론] L03 지구의형상과좌표체계[공간정보시스템 개론] L03 지구의형상과좌표체계
[공간정보시스템 개론] L03 지구의형상과좌표체계
 
[공간정보시스템 개론] L02 공간정보와 지리정보
[공간정보시스템 개론] L02 공간정보와 지리정보[공간정보시스템 개론] L02 공간정보와 지리정보
[공간정보시스템 개론] L02 공간정보와 지리정보
 
[공간정보시스템 개론] L01 공간정보시스템개요
[공간정보시스템 개론] L01 공간정보시스템개요[공간정보시스템 개론] L01 공간정보시스템개요
[공간정보시스템 개론] L01 공간정보시스템개요
 
[공간정보시스템 개론] L12 공간정보분석
[공간정보시스템 개론] L12 공간정보분석[공간정보시스템 개론] L12 공간정보분석
[공간정보시스템 개론] L12 공간정보분석
 
[공간정보시스템 개론] L11 공간정보의 구축
[공간정보시스템 개론] L11 공간정보의 구축[공간정보시스템 개론] L11 공간정보의 구축
[공간정보시스템 개론] L11 공간정보의 구축
 
[공간정보시스템 개론] L10 수치표고모델
[공간정보시스템 개론] L10 수치표고모델[공간정보시스템 개론] L10 수치표고모델
[공간정보시스템 개론] L10 수치표고모델
 
[공간정보시스템 개론] L09 공간 데이터 모델
[공간정보시스템 개론] L09 공간 데이터 모델[공간정보시스템 개론] L09 공간 데이터 모델
[공간정보시스템 개론] L09 공간 데이터 모델
 
[공간정보시스템 개론] L08 gnss의 개념과 활용
[공간정보시스템 개론] L08 gnss의 개념과 활용[공간정보시스템 개론] L08 gnss의 개념과 활용
[공간정보시스템 개론] L08 gnss의 개념과 활용
 
[공간정보시스템 개론] L07 원격탐사의 개념과 활용
[공간정보시스템 개론] L07 원격탐사의 개념과 활용[공간정보시스템 개론] L07 원격탐사의 개념과 활용
[공간정보시스템 개론] L07 원격탐사의 개념과 활용
 
[공간정보시스템 개론] L06 GIS의 이해
[공간정보시스템 개론] L06 GIS의 이해[공간정보시스템 개론] L06 GIS의 이해
[공간정보시스템 개론] L06 GIS의 이해
 
[공간정보시스템 개론] L05 우리나라의 수치지도
[공간정보시스템 개론] L05 우리나라의 수치지도[공간정보시스템 개론] L05 우리나라의 수치지도
[공간정보시스템 개론] L05 우리나라의 수치지도
 
Swift 3 Programming for iOS : Protocol
Swift 3 Programming for iOS : ProtocolSwift 3 Programming for iOS : Protocol
Swift 3 Programming for iOS : Protocol
 
Swift 3 Programming for iOS : extension
Swift 3 Programming for iOS : extensionSwift 3 Programming for iOS : extension
Swift 3 Programming for iOS : extension
 
Swift 3 Programming for iOS : Enumeration
Swift 3 Programming for iOS : EnumerationSwift 3 Programming for iOS : Enumeration
Swift 3 Programming for iOS : Enumeration
 

Swift 3 Programming for iOS : data type

  • 1. Swift 3 : Data Types 군산대학교 컴퓨터정보통신공학부 컴퓨터정보공학전공 남 광 우 kwnam@kunsan.ac.kr Swift 3 Tour and Language Guide by Apple 꼼꼼한 재은씨의 Swift 2 프로그래밍
  • 2. Data Type 개요 • Swift에서 모든 데이터 타입은 객체 • Int , float 등 모든 type이 객체 • C에서의 int는 atomic type • Java에서는 int Type과 Integer(객체)로 구분 사용 • 그래서.. • 3.distanceTo( 5)    : (O) • Int.max :  (O)
  • 3. Simple Values • 변수와 상수의 선언 • 타입의 추정 var myVariable = 42  // 변수 myVariable = 50 let myConstant = 42 // 상수 let implicitInteger = 70 let implicitDouble = 70.0 let explicitDouble: Double = 70
  • 4. Simple Values • 서로 다른 타입 값의 변환 • 변수 상수의 이름은 한글 한자도 가능 let label = "The width is " let width = 94 let widthLabel = label + String(width) var 한글변수 = 3 let ㅎㄱㅂㅅ = 5.3
  • 5. 기본 자료형 • Int • Int8, Int16, Int32, Int64 • Uint • UInt8, UInt16, UInt32, UInt64 • Double & Float • Bool • String • Character
  • 6. 기본 자료형 • 자료형의 선언과 사용의 세가지 방법 // first var day = 7 // second var day : Int day = 7 //  third var day : Int = 7 // 다음은 error!!!! var day  day = 7
  • 7. 닫힌 범위 연산자 • 범위 값을 나타내는 연산 • 1…5  : 1, 2, 3, 4, 5 • 1..<5 : 1, 2, 3, 4 • for 문에서의 사용 • hello 100번 print 하기 for  i in 1…100 { print( “Hello” ) }
  • 8. 문자열 template • 변수, 상수 값을 대입하기 위한 template • (이스케이프) 문자의 사용 • hello world  1..<100 까지 번호와 함께 찍기 let apples = 3 let oranges = 5 let appleSummary = "I have (apples) apples." let fruitSummary = "I have (apples + oranges) pieces of fruit.
  • 9. Type Aliases • Type 선언을 할 수 있음 • 객체 메소드 그대로 사용 가능 typealias AudioSample = UInt16 var maxAmplitudeFound = AudioSample.min // maxAmplitudeFound is now 0
  • 10. Tuple • Tuple • 다수개의 쌍으로 표현되는 데이터 모음 타입 • return 타입으로 사용가능 • 선언 • 사용 예 let http404Error = (404, "Not Found") // http404Error is of type (Int, String), and  equals (404, "Not Found") let (statusCode, statusMessage) = http404Error print("The status code is (statusCode)") // Prints "The status code is 404" print("The status message is (statusMessage)") // Prints "The status message is Not Found"
  • 11. Tuple • Tuple에서의 _ • Tuple에서의 individual element name let (justTheStatusCode, _) = http404Error print("The status code is (justTheStatusCode)") // Prints "The status code is 404" let http200Status = (statusCode: 200, description: "OK") print("The status code is (http200Status.statusCode)") // Prints "The status code is 200“ print("The status message is (http200Status.description)") // Prints "The status message is OK"