You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
변수와 상수
변수
var
변수의 특징
문자열 보간법 (String Interpolation)
\\(변수명)
상수
let
상수의 특징
데이터 타입
Swift 는 모든 타입에 대문자를 사용한다.
Int
Float
소수점 표현가능
6자리 까지의 정보를 정확하게 저장 (정수/소수점 포함)
4바이트 (32비트)
CGFloat
Core Graphics 및 관련 프레임워크의 부동 소수점 스칼라 값에 대한 기본 유형
64비트 CPU - 64비트
32비트 CPU - 32비트
Double
Character
ex)
“A”
,“c”
,“가"
,“ ”
...String
ex)
“안녕하세요"
,“hello”
,“”
...Bool
true
또는false
를 저장기타
UInt
: 양수 Int 타입 (UInt
타입에Int
를 넣을 수 없다.)UInt64
,Int32
...변수와 타입
타입 변환 (Conversion)
“123”
→Int(”123”)
→123
(Int)“안녕"
→Int(”안녕")
→nil
123.45
→Int(123.45)
→123
(소수점 사라짐)<aside> 💡 데이터가 변환이 되지 않거나, 데이터가 유실 될 수 있다는 점을 주의해야한다.
</aside>
타입 애일리어스 (Type Alias)
String
을Name
이라는 별칭으로 사용한다.<aside> 💡 기존에 존재하는 타입 등에서 새로운 별명/별칭을 붙여 가독성을 높인다.
</aside>
Apple Developer Documentation
연산자
<aside> 💡 같은 타입의 데이터 끼리만 연산 및 저장이 가능하다.
</aside>
단항연산자 (Unary Operator)
+a
-a
!a
a...
이항연산자 (Binary Operator)
a + b
a >= b
삼항연산자 (Ternary Operator)
a ? b : c
할당연산자 (Assignment)
a = a + 7
산술연산자 (Arithmetic)
+
-
*
/
%
복합 할당 연산자 (Compound Assignment)
비교연산자 (Comparison)
==
!=
>
<
>=
<=
논리연산자 (Logical)
!
&&
||
연산의 우선순위
**높음**
*
/
%
+
-
==
!=
>
<
>=
<=
~=
&&
||
삼항연산자
할당
낮음
접근연산자 (.)
명시적 멤버 표현식 (Explicit Member Expression)
변수와 상수
변수
var
변수의 특징
문자열 보간법 (String Interpolation)
\(변수명)
상수
let
상수의 특징
데이터 타입
Swift 는 모든 타입에 대문자를 사용한다.
Int
Float
소수점 표현가능
6자리 까지의 정보를 정확하게 저장 (정수/소수점 포함)
4바이트 (32비트)
CGFloat
Core Graphics 및 관련 프레임워크의 부동 소수점 스칼라 값에 대한 기본 유형
64비트 CPU - 64비트
32비트 CPU - 32비트
Double
Character
ex)
“A”
,“c”
,“가"
,“ ”
...String
ex)
“안녕하세요"
,“hello”
,“”
...Bool
true
또는false
를 저장기타
UInt
: 양수 Int 타입 (UInt
타입에Int
를 넣을 수 없다.)UInt64
,Int32
...변수와 타입
타입 변환 (Conversion)
“123”
→Int(”123”)
→123
(Int)“안녕"
→Int(”안녕")
→nil
💡 데이터가 변환이 되지 않거나, 데이터가 유실 될 수 있다는 점을 주의해야한다.123.45
→Int(123.45)
→123
(소수점 사라짐)타입 애일리어스 (Type Alias)
💡 기존에 존재하는 타입 등에서 새로운 별명/별칭을 붙여 가독성을 높인다.String
을Name
이라는 별칭으로 사용한다.Apple Developer Documentation
연산자
💡 같은 타입의 데이터 끼리만 연산 및 저장이 가능하다.단항연산자 (Unary Operator)
+a
-a
!a
a...
이항연산자 (Binary Operator)
a + b
a >= b
삼항연산자 (Ternary Operator)
a ? b : c
할당연산자 (Assignment)
a = a + 7
산술연산자 (Arithmetic)
+
-
*
/
%
복합 할당 연산자 (Compound Assignment)
비교연산자 (Comparison)
==
!=
>
<
>=
<=
논리연산자 (Logical)
!
&&
||
연산의 우선순위
**높음**
*
/
%
+
-
==
!=
>
<
>=
<=
~=
&&
||
삼항연산자
할당
낮음
접근연산자 (.)
명시적 멤버 표현식 (Explicit Member Expression)
Beta Was this translation helpful? Give feedback.
All reactions