'IOS/Swift 문법'에 해당되는 글 12건

  1. 2016.05.22 XCode 단축키
  2. 2016.05.20 0. 공부 준비물
  3. 2016.05.20 10 문법을 마무리하며..
  4. 2016.05.20 9. Optional Value
  5. 2016.05.20 8. struct
  6. 2016.05.20 7. class
  7. 2016.05.20 6. Functions
  8. 2016.05.20 5. Conditional Statements
  9. 2016.05.20 4. Control Flow
  10. 2016.05.19 3. Dictionary

XCode 단축키

IOS/Swift 문법 2016. 5. 22. 11:16

기본적인 맥 단축키

 - 커맨드 + A  : 전체 선택

 - 커맨드 + Z  : 되돌리기

 - 커맨드 + X  : 자르기

 - 커맨드 + C  : 복사

 - 커맨드 + V  : 붙여넣기

 - 커맨드 + BackSpace : 해당 라인 지우기

 - 커맨드 + 방향키  : 해당 방향의 끝으로 이동

   # 커맨드 + Up : 해당 창 가장 위로

     = Home 키도 동일하게 작동합니다.

   # 커맨드 + Down : 해당 창 가장 아래로

     = End 키도 동일하게 작동합니다.

   # 커맨드 + Left : 선택된 텍스트라인 가장 왼쪽으로

   # 커맨드 + Right : 선택된 텍스트라인 가장 오른쪽으로

 - 컨트롤 + 좌/우 : 페이지 변경

 - 커맨드 + Shift + 4 : 선택한 화면 영역 캡쳐

 - 커맨드 + Space : 언어 변환

 - 커맨드 + Space, 커맨드 누른채로 Space 연타 시 다음 언어로 선택 가능.

 - 커맨드 + W : 현재 창 닫기

 - 커맨드 + Q : 선택된 프로그램 종료

 - 커맨드 + H : 현재 창 숨기기

 - 컨트롤 + Space : Spotlight 검색


XCode 

 - 커맨드 + Shift + K  : 프로젝트 클린

 - 커맨드 + B  : 프로젝트 빌드

 - 커맨드 + R  : 프로젝트 실행

 - 커맨드 + I  : 프로젝트 프로파일링 빌드

 - 커맨드 + . : 실행중인 앱 강제 종료

 - 커맨드 + , : XCode 프로퍼티창 열기

  # 해당 창에 Key Bindings 탭에서 모든 단축키를 변경할 수 있습니다. 단, 꼬이면 답이 없습니다..


 - 커맨드 + Shift + O : 프로젝트 내 파일 / 클래스 / 함수 검색 ( 매우 유용 )

 - 커맨드 + Shift + F : 파인드 창으로 캐럿 강제 이동

 - 커맨드 + F : 현재 창 검색

 - 커맨드 + E : 현재 선택된 텍스트 블럭을 모든 텍스트에디트에 복사 ( ?.. 설명을 잘 못하겠네요... )

 - 커맨드 + G : 현재 페이지에 텍스트에디트에 적힌 문구 순차 검색 ( 위 커맨드 + E 와 활용도 매우 높습니다 )

 - 커맨드 + Shift + G : 현재 페이지에 텍스트에디트에 적힌 문구 역순차 검색

 - 커맨드 + alt + Enter : 현재창 이중 분할

 - 커맨드 + Enter : 현재창을 단일창으로 변경

 - 커맨드 + 0 : 왼쪽에 프로젝트 파인더 및 검색 등등 윈도우 숨기기 & 열기

 - 커맨드 + 1 : 프로젝트 파인더 열기

 - 커맨드 + 2 : 프로젝트 하이라키 창 열기

 - 커맨드 + 3 : 프로젝트 검색 창 열기

 - 커맨드 + 4 : 프로젝트 워닝 및 에러 창 열기

 - 커맨드 + 5 : 테스트 타겟창 열기

 - 커맨드 + 6 : 디버그 세션 창 열기

 - 커맨드 + 7 : 프로젝트에 걸려있는 모든 브레이크 포인트를 보여주는 창 열기

 - 커맨드 + 8 : 빌드 관련 히스토리 ?


 - 커맨드 + \ : 브레이크 포인트 걸기

 - 커맨드 + Y : 브레이크 포인트 비활성화 / 활성화

 - 커맨드 + Shift + Y : 하단 디버그 세션 창 열기 / 닫기 

 - 커맨드 + / : 해당라인 주석 걸기 ( 다중 라인도 가능 )

 - 컨트롤 + 커맨드 + 좌우 화살표 : 이전/이후 페이지 이동

 - 커맨드 + [ ] : 해당 방향으로 들여쓰기

 - 컨트롤 + I : 선택된 텍스트블록의 들여쓰기 올바르게(?) 적용


디버깅 관련

 - F6 : 다음 라인 ( Step Over )

 - F7 : 현재 라인 내부 진입 ( Step Into )

 - F8 : 현재 함수에서 나가기 ( Step Out )

 - 커맨드 + Shift + Y : 실행 중 멈춤 ( Pause ) & 멈춤 상태에서 재 진행


소스 컨트롤 관련

 - 커맨드 + Shift + C : 커밋창 열기

 - 커맨드 + Shift + X : 업데이트 하기


iOS Simulator

 - 커맨드 + S : 현재 시뮬레이터에 뜬 화면 캡쳐



'IOS > Swift 문법' 카테고리의 다른 글

0. 공부 준비물  (0) 2016.05.20
10 문법을 마무리하며..  (0) 2016.05.20
9. Optional Value  (0) 2016.05.20
8. struct  (0) 2016.05.20
7. class  (0) 2016.05.20
Posted by Hoya0415
,

 Swift 공부를 하려고 합니다. 글쓴이도 공부하면서 그때 그때 배운 내용을 가지고 이해가 된다면 블로그에 작성하여 

여러분들에게 차근차근 알려줘서 같이 스킬 업 할 수 있게 하려고 합니다.

준비물을 알려드릴게요.


1. 첫번째는 개발도구인    XCODE  입니다. 


2. 두번째는 iBook 에서 The Swift Programming Language 책을 다운 받습니다. 엄청 유용한 문법 책이에요!

시중 책을 사실 필요 없어요

( 이 책을 보면서 공부하면 된다. 단지 영어로 되어 있지만, 코드를 보면서 구글 번역이라도 해서 봐야해요)

3. 세번째는 App 개발에 필요한 Library 설명이 들어있는 문서에요 중요합니다.

 XCODE 실행 후 Menu->Window -> Document and API Reference 



'IOS > Swift 문법' 카테고리의 다른 글

XCode 단축키  (0) 2016.05.22
10 문법을 마무리하며..  (0) 2016.05.20
9. Optional Value  (0) 2016.05.20
8. struct  (0) 2016.05.20
7. class  (0) 2016.05.20
Posted by Hoya0415
,

여기까지 오신 여러분은 이제 개발을 할 수 있는 단계라고 볼 수 있다.


문법 강좌는 여기까지로 마치며, 만약 자신이 부족한 것 같다고 생각이 든다면  다시 한번 코딩을 해보고 습득 하길 권하고


이제부터 콘솔 프로그램이나.. 응용프로그램을 만들 것이다.


우리가 원하는게 이런 문법이 아닌 아이폰이나 맥으로 돌아가는 프로그램을 만드는 일이다


조금만 더 노력하면 여러분이 원하는 앱을 만들 수 있다.. 


실제 Xcode 문서를 보면서 Foundation Framework cocoa touch 알아야 아이폰 앱을 개발할 수 있다..

'IOS > Swift 문법' 카테고리의 다른 글

XCode 단축키  (0) 2016.05.22
0. 공부 준비물  (0) 2016.05.20
9. Optional Value  (0) 2016.05.20
8. struct  (0) 2016.05.20
7. class  (0) 2016.05.20
Posted by Hoya0415
,

9. Optional Value

IOS/Swift 문법 2016. 5. 20. 16:07
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//: Playground - noun: a place where people can play
 
import UIKit
 
class Optional{
    //lapping
    var optionalString:String= "Hello"
    
    func hello(){
    //optionalString = nil
        //unlapping
        print(optionalString)
    }
}
 
var option = Optional()
option.hello()
cs


Optional을 출력하면 Lapping 상태의 값이 나올 것이다.

우리가 원하는 출력 값이 아니다.

unlapping 해주면 값이 제대로 출력 될 것이다.





'IOS > Swift 문법' 카테고리의 다른 글

0. 공부 준비물  (0) 2016.05.20
10 문법을 마무리하며..  (0) 2016.05.20
8. struct  (0) 2016.05.20
7. class  (0) 2016.05.20
6. Functions  (0) 2016.05.20
Posted by Hoya0415
,

8. struct

IOS/Swift 문법 2016. 5. 20. 15:46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//: Playground - noun: a place where people can play
 
import UIKit
 
var name = ["Park" ,"Choi","Kim""Lee"]
var age = [3,4,5,6]
var height  = [40,50,60,70]
 
print(name[0], age[0],height[0])
 
struct Student {
    var name:String
    var age:Int
    var height:Int
    
}
 
var student1 = Student(name: "Park", age: 3, height: 40)
var student2 = Student(name: "Choi", age: 4, height: 50)
 
struct Student2 : Student {
    
}
cs

struct cann't apply inheritance 


struct Student2 : Student {
    
}


'IOS > Swift 문법' 카테고리의 다른 글

10 문법을 마무리하며..  (0) 2016.05.20
9. Optional Value  (0) 2016.05.20
7. class  (0) 2016.05.20
6. Functions  (0) 2016.05.20
5. Conditional Statements  (0) 2016.05.20
Posted by Hoya0415
,

7. class

IOS/Swift 문법 2016. 5. 20. 15:34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//: Playground - noun: a place where people can play
 
import UIKit
 
//class object
class Vehicle{
    var currentSpeed = 0.0
    //stored property
    
    //Computed property
    var description : String {
        return "traveling at \(currentSpeed) miles per hour"
            }
    
    //Calling Method in Class
    func makeNoise()
    {
        
    }
}
 
 
let someVehicle = Vehicle();
 
print("Vehicle : \(someVehicle.description)")
 
class Bicycle : Vehicle {
    
    var hasBasket = false
}
 
let bicycle = Bicycle()
bicycle.hasBasket = true;
bicycle.currentSpeed = 15.0
print("Bicycle : \(bicycle.description)")
 
class Tandem : Bicycle
{
    var currentNumberOfPassengers = 0
}
 
let tandom = Tandem()
tandom.hasBasket = true
tandom.currentNumberOfPassengers = 2
tandom.currentSpeed = 22.0
 
print("Tandem : \(tandom.description)")
 
class Train:Vehicle
{
    override func makeNoise() {
        print("Choo Choo")
        
    }
}
 
let train  = Train()
train.makeNoise()
cs

You define properties and methods to add functionality to your classes and structures by using exactly the same syntax as for constants, variables, and functions.


class는 상속받은 부모 클래스의 함수를 재정의 (override) 할 수 있다.


class와 structures 의 차이

class는 상속이 가능하지만 structures 는 불가능하다.


Classes and structures in Swift have many things in common. Both can:

Define properties to store values

Define methods to provide functionality

Define subscripts to provide access to their values using subscript syntax

Define initializers to set up their initial state

Be extended to expand their functionality beyond a default implementation

Conform to protocols to provide standard functionality of a certain kind

For more information, see Properties, Methods, Subscripts, Initialization, Extensions, and Protocols.


Classes have additional capabilities that structures do not:

Inheritance enables one class to inherit the characteristics of another.

Type casting enables you to check and interpret the type of a class instance at runtime.

Deinitializers enable an instance of a class to free up any resources it has assigned.

Reference counting allows more than one reference to a class instance.”



'IOS > Swift 문법' 카테고리의 다른 글

9. Optional Value  (0) 2016.05.20
8. struct  (0) 2016.05.20
6. Functions  (0) 2016.05.20
5. Conditional Statements  (0) 2016.05.20
4. Control Flow  (0) 2016.05.20
Posted by Hoya0415
,

6. Functions

IOS/Swift 문법 2016. 5. 20. 14:29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//: Playground - noun: a place where people can play
 
import UIKit
 
func sayHello()
{
    print("Hello")
}
 
sayHello()
 
func sayHello2(name:String)
{
    print("Hello \(name)")
}
 
sayHello2("Programmer")
 
func sayHelloi3(name:String = "defaultValue")
{
    print("Hello \(name)")
}
 
sayHelloi3("Song")
 
func sayHello4(name2 name:String="Song",age2 age:Int-> String
{
    
    return "Hello \(name) is \(age) years old"
}
 
print(sayHello4(name2:"Song", age2: 3))
 
 
func sayHello5( name:String="Song", age:Int-> String
{
    
    return "Hello \(name) is \(age) years old"
}
 
print(sayHello5("Song", age: 3))
 
 
func sayHello6( name:String="Song", _ age:Int-> String
{
    
    return "Hello \(name) is \(age) years old"
}
 
print(sayHello6("Song"3))
cs


'IOS > Swift 문법' 카테고리의 다른 글

8. struct  (0) 2016.05.20
7. class  (0) 2016.05.20
5. Conditional Statements  (0) 2016.05.20
4. Control Flow  (0) 2016.05.20
3. Dictionary  (0) 2016.05.19
Posted by Hoya0415
,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
import UIKit
 
//if
let age = 7
 
if age < 3
{
    print("Baby")
}
else if age >= 3 && age < 20
{
    print("child")
}
else{
    print("adult")
}
 
//Switch
 
switch age
{
    case 1..<3:print("Baby")
    
    case 3..<20:print("Child")
    
    default : print("Adult")
}
 
 
switch age
{
case 0,3,11,12 :print("Baby")
    
case 4...10:print("Child")
    
default : print("Adult")
}
 
cs


'IOS > Swift 문법' 카테고리의 다른 글

7. class  (0) 2016.05.20
6. Functions  (0) 2016.05.20
4. Control Flow  (0) 2016.05.20
3. Dictionary  (0) 2016.05.19
2. Array  (0) 2016.05.18
Posted by Hoya0415
,

4. Control Flow

IOS/Swift 문법 2016. 5. 20. 09:30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//: Playground - noun: a place where people can play
 
import UIKit
 
var age = 0
 
while age < 5
{
    print(age)
    age++
}
 
for var age2 = 0; age2<=5; age2++
{
    print("age2 : \(age2)")
}
 
for _ in 1...5{
    print("5")
}
 
for number in 1...5{
    print(number)
}
 
for name in ["Anna""Alex","Brian","Jack"]
{
    print("hello, \(name)")
}
 
for (animalName, legs) in ["ant":6,"snake":0,"cheetah":4]
{
    print("\(animalName)'s have \(legs) legs")
}
 
for index in 1...5 {
    
    print("\(index) items 5 is \(index * 5)")
    
}
cs

for-In Loops structure :

Closed range operator(...)

for index in 1...5 {
    
    print("\(index) items 5 is \(index * 5)")
    
}

underscore character ( _ ) : don't provide  access to the current value during each iteration of the loop

for _ in 1...5{
    print("5")
}
 

for-in loop with an array to iterate over its 

1
2
3
4
for name in names
{
    print("Hello, \(name)!")
}
cs

You can also iterate over a dictionary to access its key-value pairs

1
2
3
4
5
6
let numberOfLegs = ["spider":8,"ant":6,"cat":4]
 
for(animalName, legCount) in numberOfLegs
{
    print("\(animalName)s have \(legCount) legs")
}
cs


'IOS > Swift 문법' 카테고리의 다른 글

6. Functions  (0) 2016.05.20
5. Conditional Statements  (0) 2016.05.20
3. Dictionary  (0) 2016.05.19
2. Array  (0) 2016.05.18
1. 상수와 변수  (0) 2016.05.18
Posted by Hoya0415
,

3. Dictionary

IOS/Swift 문법 2016. 5. 19. 22:04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

//: Playground - noun: a place where people can play

import UIKit

 
//mutable dictionary
var legs:Dictionary<String,Int> = [:]
 
var legs2:[String:Int= [:]
 
legs2["ant"= 6
legs2["snake"= 0
print(legs2)
 
var legs3 = ["ant":6"snake":0"cheetah":4]
 
print(legs3)
 
legs3["human"= 2
 
print(legs3)
 
//immutable dictionary
let legs4 = ["ant":6"snake":0"cheetah":4]
 
 
if(legs4.isEmpty)
{
    print("Didn't have Data")
}
else
{
    print("had Data")
    
    legs3["snake"= 10
    
    print(legs3)
}
 
 
var legs5:[String:String= ["YYZ":"Toronto","DUB":"Dublin",
"DUB2":"Dublin2"]
 
print(legs5)
 
for (legValue, legType) in legs5{
    print("\(legValue): \(legType)")
}
cs

written in full as :

Dictionary<Key, Value>

Creating an Empty Dictionary as :

var nameOfIntegers =[Int:String] ()

var nameOfIntegers:[Int:String] = [:]




'IOS > Swift 문법' 카테고리의 다른 글

6. Functions  (0) 2016.05.20
5. Conditional Statements  (0) 2016.05.20
4. Control Flow  (0) 2016.05.20
2. Array  (0) 2016.05.18
1. 상수와 변수  (0) 2016.05.18
Posted by Hoya0415
,