<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Developers</title>
    <link>https://developers.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Wed, 6 May 2026 11:17:17 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>dnsdud</managingEditor>
    <image>
      <title>Developers</title>
      <url>https://t1.daumcdn.net/cfile/tistory/1560D40E4B459EE83F</url>
      <link>https://developers.tistory.com</link>
    </image>
    <item>
      <title>App Extension 을 위한 App Group 생성하기</title>
      <link>https://developers.tistory.com/146</link>
      <description>&lt;h1&gt;Share Extension 앱그룹 생성하기&lt;/h1&gt;&lt;p&gt;앱 그룹을 만들기 위한 Step-By-Step&lt;br /&gt;&lt;br /&gt;iOS8 부터 지원되는 Extension 의 기능을 활용하기 위해서는 App Group 을 만들어서 묶어 줘야 합니다.&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;&lt;ol&gt;&lt;li&gt;기본 App ID 생성, 생성시 App Groups 에 체크를 하고 진행해 줍니다.&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 820px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/24342133596C9D7B08&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F24342133596C9D7B08&quot; width=&quot;820&quot; height=&quot;454&quot; filename=&quot;스크린샷 2017-07-17 오후 8.04.15.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;ID 는 기본이 되는 앱과 Extension 를 위한 앱 각각 1개씩 생성되어야 합니다.(Today 등 다른 Extension 사용시 각기 하나)&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 820px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2322C633596C9D9E31&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2322C633596C9D9E31&quot; width=&quot;820&quot; height=&quot;132&quot; filename=&quot;스크린샷 2017-07-17 오후 8.05.07.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;ID 생성 후 그룹 생성을 위한 항목으로 이동합니다.&lt;br /&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 742px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/27E59133596C9E190D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F27E59133596C9E190D&quot; width=&quot;742&quot; height=&quot;604&quot; filename=&quot;스크린샷 2017-07-17 오후 8.05.16.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;그룹 생성시 ID는 일관성 있게 해주는게 좋습니다.&lt;br /&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 820px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/24544133596C9E1A21&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F24544133596C9E1A21&quot; width=&quot;820&quot; height=&quot;249&quot; filename=&quot;스크린샷 2017-07-17 오후 8.05.37.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;기본으로 생성한 ID 항목을 선택하면 아래와 같이 App Groups 항목 설정이 필요하다고 나옵니다.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 820px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/22BEB333596C9E1B12&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F22BEB333596C9E1B12&quot; width=&quot;820&quot; height=&quot;219&quot; filename=&quot;스크린샷 2017-07-17 오후 8.06.00.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;하단에 Edit 를 누르면 아래와 같이 수정이 가능합니다.&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 820px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/26E57D33596C9E1C0D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F26E57D33596C9E1C0D&quot; width=&quot;820&quot; height=&quot;166&quot; filename=&quot;스크린샷 2017-07-17 오후 8.06.09.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;text-align: left;&quot;&gt;앞서 만들어 둔 App Groups 항목을 선택해 줍니다.(Assign)&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 820px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/210D2B33596C9E1C07&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F210D2B33596C9E1C07&quot; width=&quot;820&quot; height=&quot;51&quot; filename=&quot;스크린샷 2017-07-17 오후 8.06.18.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;위 작업은 기본앱과 Extension 앱 ID 모두 수행을 해줘야 합니다. 각기 ID 에 App Groups 항목이 사용가능하게 바뀌었는지 확인해줍니다.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 820px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2797C933596C9E1D17&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2797C933596C9E1D17&quot; width=&quot;820&quot; height=&quot;228&quot; filename=&quot;스크린샷 2017-07-17 오후 8.06.52.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;이상입니다.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;
&lt;br /&gt;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/146</guid>
      <comments>https://developers.tistory.com/146#entry146comment</comments>
      <pubDate>Mon, 17 Jul 2017 20:27:06 +0900</pubDate>
    </item>
    <item>
      <title>Property Observer</title>
      <link>https://developers.tistory.com/145</link>
      <description>&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot; style=&quot;margin: 0px; width: 375px; height: 356px;&quot;&gt;class StepCounter {
    var totalSteps: Int = 0 {
        willSet {
            println(&quot;About to set totalSteps to \(newValue)&quot;)
        }
        didSet {
            if totalSteps &amp;gt; oldValue  {
                println(&quot;Added \(totalSteps - oldValue) steps&quot;)
            }
        }
    }
}
let stepCounter = StepCounter()
stepCounter.totalSteps = 200
// About to set totalSteps to 200
// Added 200 steps
stepCounter.totalSteps = 360
// About to set totalSteps to 360
// Added 160 steps
stepCounter.totalSteps = 896
// About to set totalSteps to 896
// Added 536 steps

&lt;/textarea&gt;&lt;/pre&gt;&lt;pre&gt;&lt;p&gt;&lt;span style=&quot;font-family: 돋움; font-size: 9pt; line-height: 1.5;&quot;&gt;  와~ 옵저버다 세팅되기 전에 호출 되고 세팅되고 호출 되는 거 외엔 크게 별다른거 없어 보이는데 기존에(Obj-C) 로&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 돋움; font-size: 9pt; line-height: 1.5;&quot;&gt;  속성값이 변경되거나 할때 굳이 Observer 생성해서 달아 주고 할 필요가 없어졌다는게 참 좋은듯 하다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 돋움; font-size: 9pt; line-height: 1.5;&quot;&gt;  부가적으로&lt;/span&gt;&lt;/p&gt;&lt;p&gt; - willSet 에 이름 생략시 newValue 로 접근&lt;/p&gt;&lt;p&gt; - didSet 에 이름 생략시 oldValue 로 접근&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 돋움; font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 돋움; font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 돋움; font-size: 9pt; line-height: 1.5;&quot;&gt;  &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 돋움; font-size: 9pt; line-height: 1.5;&quot;&gt;  &lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <category>Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/145</guid>
      <comments>https://developers.tistory.com/145#entry145comment</comments>
      <pubDate>Mon, 3 Aug 2015 18:21:21 +0900</pubDate>
    </item>
    <item>
      <title>Struct</title>
      <link>https://developers.tistory.com/144</link>
      <description>&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot; style=&quot;margin: 0px; width: 553px; height: 549px;&quot;&gt;
struct Point {
    var x = 0.0, y = 0.0
}

struct Size {
    var width = 0.0, height = 0.0
}

struct Rect {
    var origin = Point()
    var size = Size()
    var center : Point {
        get {
            let centerX = origin.x + (size.width / 2)
            let centerY = origin.y + (size.height / 2)
            println(&quot;get 속성이 호출되었습니다&quot;)
            return Point(x:centerX, y:centerY)
        }
        set {
            origin.x = newValue.x - (size.width / 2)
            origin.y = newValue.y - (size.height / 2)
            println(&quot;set 속성이 호출되었습니다&quot;)
        }
    }
    var scale : Int {
        return Int(size.width) * Int(size.height)
    }
    
}

var square = Rect(origin: Point(x: 0.0, y: 0.0), size: Size(width: 10.0, height: 10.0))
println(&quot;Rect를 생성했습니다&quot;)
let initialSquareCenter = square.center
println(&quot;initialSquareCenter를 선언했습니다&quot;)
square.center = Point(x: 15.0, y: 15.0)
println(&quot;Point를 사용해서 square.center를 설정했습니다&quot;)

println(&quot;square.origin is now at (\(square.origin.x), \(square.origin.y) : \(square.scale))&quot;)


&lt;/textarea&gt;&lt;/pre&gt;&lt;pre&gt;&lt;p&gt;  Struct 는 굳이 크게 쓸일이 없을 것 같아서... 예제를 거의 그대로 긁어 왔다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;  Line 19 에서 set 될 값의 이름을 생략하면 newValue로 접근 가능하다는 것과&lt;/p&gt;&lt;p&gt;  Line 25 의 get 키워드 없이 그냥 return 으로 쓸수 있다는 거외엔 특이한게 별로..&lt;/p&gt;&lt;/pre&gt;&lt;pre&gt;  &lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <category>Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/144</guid>
      <comments>https://developers.tistory.com/144#entry144comment</comments>
      <pubDate>Mon, 3 Aug 2015 17:03:38 +0900</pubDate>
    </item>
    <item>
      <title>Enum</title>
      <link>https://developers.tistory.com/143</link>
      <description>&lt;p&gt;&amp;nbsp; 기본적인 선언 형태&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot; style=&quot;margin: 0px; width: 258px; height: 246px;&quot;&gt;enum My_Enum : Int    {
    case JAN
    case FEB
    case MAR
}

var enumValue : My_Enum = My_Enum.MAR
switch(enumValue)
{
case .JAN:
    println(enumValue.rawValue)
case .FEB:
    println(enumValue.rawValue)
default:
    println(enumValue.rawValue)
}

&lt;/textarea&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 아래와 같이 이전처럼 값을 지정할 수도 있다.&lt;/p&gt;


&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot; style=&quot;margin: 0px; width: 258px; height: 246px;&quot;&gt;enum My_Enum2 : Int {
    case A  =  41
    case B
    case C
    case D
}
&lt;/textarea&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; 위와 같은 형태가 이전에 쓰이던 형태라면 아래와 같은 경우도 가능하다&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot; style=&quot;margin: 0px; width: 257px; height: 238px;&quot;&gt;enum My_Enum3 : String {
    case A = &quot;1&quot;
    case B = &quot;2&quot;
    case C = &quot;3&quot;
    case D = &quot;4&quot;
}

enum My_Enum4 {
    case A(Int, String)
    case B(String, String)
    case C(Int, Int, Int)
}

&lt;/textarea&gt;&lt;/pre&gt;&lt;pre&gt;  머리가 아파오기 시작 ㅠ_ㅠ&lt;/pre&gt;&lt;pre&gt;&lt;p&gt;  Enum3 의 경우는 String 도 지정가능 하다는 거고(String 도 이제 Switch 에서 단순 비교로 쓰이는게 가능하니)&lt;/p&gt;
&lt;p&gt;  Enum4 의 경우는 연관된 값들로 구성도 가능하다는 것이다.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;  당장에 어디다 써야지 싶은 느낌은 안드는..&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot; style=&quot;margin: 0px; width: 264px; height: 219px;&quot;&gt;
var associated : My_Enum4 = .A(1,&quot;2&quot;)
var associated2 : My_Enum4 = .B(&quot;3&quot;, &quot;4&quot;)

let switchTestValue = associated;

switch(switchTestValue) {
case .A(let intValue, let stringValue):
    println(&quot;\(intValue) __ \(stringValue)&quot;)
case .B(let stringValue1, let stringValue2):
    println(&quot;\(stringValue1) __ \(stringValue2)&quot;)
default:
    println(&quot;Else&quot;)
}


&lt;/textarea&gt;&lt;/pre&gt;&lt;p&gt;
&amp;nbsp; 일단은 아 잘나오는 구나 하고 넘어가고 나중에 다시 봐야 될법한 느낌이다.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <category>enum</category>
      <category>Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/143</guid>
      <comments>https://developers.tistory.com/143#entry143comment</comments>
      <pubDate>Mon, 3 Aug 2015 14:57:00 +0900</pubDate>
    </item>
    <item>
      <title>Closure</title>
      <link>https://developers.tistory.com/142</link>
      <description>&lt;p&gt;&amp;nbsp; 이제 드디어 Closure ㅠ_ㅠ&lt;/p&gt;&lt;p&gt;&amp;nbsp; Swift 라고 해서 새로운 언어가 나왔지만 언어가 새롭다고 해서 기존의 개념이 바뀐건 아니다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 함수형 언어라고는 하나 이러한 개념들은 60년대에 이미 논의가 되었더란다(-_-;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; 그게 중요한게 아니고... 이렇기 때문에 새로나왔다고 해서 새로운 개념이 막막 나오고 그런건 아니다&lt;/p&gt;&lt;p&gt;&amp;nbsp; Closure 라는 용어는 생소해도 Objective-C 에서 주구장창 써대던 Block 코딩이라고 생각하면 편하다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 여기저기서 Closure 의 예제로 가장 만만하게 쓰이는 sorted 의 코드로 보면 이해하기 편하다&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;var intArray : [Int] = [1,2,5,4,6,3]

var sortedArray : [Int] = sorted(intArray, { (t1 : Int, t2 : Int) -&amp;gt; Bool in
    return t1 &amp;gt; t2
})
&lt;/textarea&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp; 그리고.. 용어가 참 많이 있던데 예를들면&amp;nbsp;Inferring Type From Context, Implicit Returns from Single-Expression Closures, Shorthand Argument Names, Operator Functions 이런것들......... 굳이 번역까지 해서 용어적으로 알고 있어도 괜찮다고 보지만 굳이 그럴게 있나 싶다 일단 개념적으로만 이렇게 된다 알고 있는것도...&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;font-family: 돋움; white-space: normal;&quot;&gt;&amp;nbsp; 굳이 우리 서로 변수형 다 알고 있는 사이에 다 적어줄 필요가 있나?&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;var intArray : [Int] = [1,2,5,4,6,3]

var sortedArray : [Int] = sorted(intArray, { t1, t2 -&amp;gt; Bool in
    return t1 &amp;gt; t2
})
&lt;/textarea&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 뻔히 return 시키는게 bool 인거 아는게 return 적어줄 필요가 있나?(근데 이건 bool 만 되니 유의)&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;var intArray : [Int] = [1,2,5,4,6,3]

var sortedArray : [Int] = sorted(intArray, { t1, t2 -&amp;gt; Bool in t1 &amp;gt; t2 })
&lt;/textarea&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 뻔히 t1이니 parameter1 이니 해봐야 인자값들 받아올 뿐인데 이름 적어줄 필요있나?&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;var intArray : [Int] = [1,2,5,4,6,3]

var sortedArray : [Int] = sorted(intArray, { $0 &amp;gt; $1 })
&lt;/textarea&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 마지막 단계는 겁나 간편해 보이긴 한데 이런것들은 사용에 제한이 있다는 것에 주의하자&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이어서 &lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Trailing Closures 라는게 등장한다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 생긴건 뭔가 쫌 희안하게 생겨서 쫌 헷갈렸는데(번역된 서적보다 원문이 더 쉬운 마법의 개념) 그냥 sorted 의 경우에서 보자면 마지막으로 전달받는 인자가 Closure 이고 쫌 길다 라고 하면 유용하게 쓰일지도(?) 모른단다&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;var intArray : [Int] = [1,2,5,4,6,3]

var sortedArray : [Int] = sorted(intArray) { (t1, t2) in t1 &amp;lt; t2 }
&lt;/textarea&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp; 뭐 그냥 안에 있던게 밖으로 나왔다&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이제 Closure 항목의 마지막 단계&amp;nbsp;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Capturing Values 가 등장한다(이거 언듯 잘못보면 헷갈린다 -___-)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 지금까지는 얄팍하게 문서에 있던 예제를 야금야금 바꿨지만 이건 그대로...&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot; style=&quot;margin: 0px; width: 432px; height: 224px;&quot;&gt;func makeIncrementer(forIncrement amount: Int) -&amp;gt; () -&amp;gt; Int {
var runningTotal = 0
func incrementer() -&amp;gt; Int {
runningTotal += amount
return runningTotal
}
return incrementer
}

let incrementByTen = makeIncrementer(forIncrement: 10)
incrementByTen()
incrementByTen()
incrementByTen()
let lastValue = incrementByTen()
&lt;/textarea&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 이러니 저러니 해도 이해가 젤 중요한거 아니겠는가.. &amp;nbsp;뭐 그런 의미에서 makeIncrementer 의 리턴형에 주목하자&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; () -&amp;gt; Int 란다 근데 중요한게 블럭 안을 보면&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; var runningTotal 이라면서 변수가 하나 선언 되어 있고 그 변수를&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; function incrementer() 함수 안에서 사용하고 있다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 바로 이렇게 중첩된 함수가 존재할때 그 내부-incrementer()-에서 외부 변수-runningTotal-사용시 필요없을때 까지 유지한다는 거다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 어렵게 생각하지 말고 그 아래에&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; let incrementByTen 을 보면 makeIncrementer(forIncrement: 10) 이라는게 있다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; incrementByTen 은 함수를 반환 받고 이 반환받은 함수가 바로 makeIncrementer 내부에 있는 incrementer 다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 그래서 incrementByTen 이 해제 되기 전에는 내부의 incrementer 가 살아있고 얘가 참조하고 있는 외부의 runningTotal 이 살아있구나 라고&amp;nbsp;보면 땡!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <category>Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/142</guid>
      <comments>https://developers.tistory.com/142#entry142comment</comments>
      <pubDate>Tue, 2 Jun 2015 23:14:49 +0900</pubDate>
    </item>
    <item>
      <title>Function</title>
      <link>https://developers.tistory.com/141</link>
      <description>&lt;p&gt;&amp;nbsp; 드디어 함수&lt;/p&gt;&lt;p&gt;&amp;nbsp; 일단의 기본개념 격인 C와 별다를바 없는데서 시작한다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 기본적으로(코드 하이트 찾아서 적용해봄 으아;;)&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt; 
func funcName(Parameter:Int) -&amp;gt; (Int)
{
    return Parameter+10
}

var myValue = funcName(20)
&lt;/textarea&gt;
&lt;/pre&gt;

&lt;p class=&quot;p2&quot;&gt;&amp;nbsp; 위와 같이 함수이름과 파라미터와 리턴형을 정의해서 사용할 수 있다&lt;span class=&quot;s2&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&amp;nbsp; 몇가지 더 다양한 형태로&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func myFunc(IntName x:Int, IntName2 y:Int) -&amp;gt; (Int)
{
    return x+y
}

var myValue = myFunc(IntName: 10, IntName2: 10)
&lt;/textarea&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp; 이런식으로 외부에서 받을 이름과 내부에서 쓰일 이름을 달리 가져갈 수도 있고&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func myFunc(#x:Int, #y:Int) -&amp;gt; (Int)
{
    return x+y
}

var myValue = myFunc(x: 10, y: 10)
&lt;/textarea&gt;&lt;/pre&gt;


&lt;p&gt;&amp;nbsp; 이렇게 일치 시켜서 사용할 수도 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 여기까지는 일반적으로 파라미터 받고 반환하는 형태인데 이제 쫌 특이하게 반환 형태를 하나만 가져가는게 아니라 여러개를 반환하는 것도 가능하다&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func myFunc(#x:Int, #y:Int) -&amp;gt; (SumReturn:Int, SubReturn:Int)
{
    return (x+y, x-y)
}

var myValue = myFunc(x: 10, y: 10)
&lt;/textarea&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp; 반환하는 변수에 이름을 붙이지 않는 것도 가능하다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 그리고 보다보니 이전에 C++(이었나???) 에서 쓰던 Default 변수 형도 가능하다는 것을 발견&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func myFunc(#x:Int, #y:Int, z:Int = 0) -&amp;gt; (SumReturn:Int, SubReturn:Int)
{
    return (x+y+z, x-y-z)
}

var myValue = myFunc(x: 10, y: 10)
&lt;/textarea&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp; 이런식으로 사용도 가능하다 (# 붙이는건 Default Parameter 랑 동시에 안된다면서 빼버리더라...)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 그리고 한창 포인터 공부할때 변수의 주소값을 넘겨서 해당 주소값에 바로 값을 써 버리는 방법으로 변수를 넘기는데 넘기는 Swift 에서는 다음과 같이 사용한다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func increaseOne(inout X:Int, inout Y:Int)
{
    X++;
    Y++;
}

var myX:Int = 10
var myY:Int = 20
increaseOne(&amp;amp;myX, &amp;amp;myY)
&lt;/textarea&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp; inout 만 붙여주면 된다 별거 없다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이제는 Objective-C 로 작업할때 주구장창 쓰이는 블럭코딩 같은 애가 등장한다&lt;/p&gt;&lt;p&gt;&amp;nbsp; (제대로 된건 Closure 라고 하는건 아직 진도가...)&lt;/p&gt;&lt;p&gt;&amp;nbsp; 기존에 썼던 방법이라고 해서 슥 볼려니 헷갈려 죽겠더라.. 차근차근 해보자면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 일단 개념적으로 함수는 파라미터를 받아서 결과값을 반환하는 구조이다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이런 기본 구조를 갖도 움직이다 보니 (Int, Int)-&amp;gt;Int 와 같은 형태로 정의가 가능하다(마치 변수처럼)&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이런 개념을 가지고 가면 함수의 파라미터 부분에 변수처럼 함수도 쓰임이 가능하다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func sum(x:Int, y:Int) -&amp;gt; (Int)
{
    return x+y
}
func multi(x:Int, y:Int) -&amp;gt; (Int)
{
    return x*y
}

func myFunc(myCustomFunc:(x:Int,y:Int)-&amp;gt;Int, z:Int) -&amp;gt; Int
{
    return myCustomFunc(x: z, y: z)
}

var myValue = myFunc(sum, 10)
var myValue2 = myFunc(multi, 10)
&lt;/textarea&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp; 뭔가 슬슬 우와~ 이게 가능하면 이렇게도 되겠고 저렇게도 되겠고 싶어서 머리가 슬슬 아파오기 시작할 법도 하다(?)&lt;/p&gt;&lt;p&gt;&amp;nbsp; 위와 같은 경우는 파라미터로 함수를 받았다면 이제는 반환하는 형태가 함수인 것을 보자&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func sum(x:Int, y:Int) -&amp;gt; (Int)
{
    return x+y
}
func multi(x:Int, y:Int) -&amp;gt; (Int)
{
    return x*y
}

func myFunc(x:Bool) -&amp;gt; ( (Int, Int) -&amp;gt; Int)
{
    return x ? sum : multi
}

var myValue = myFunc(true)
var myValue2 = myFunc(false)
&lt;/textarea&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp; 그럴듯한 예제의 경우가 있어서 그런식으로 쓰고 싶은데... 대충 쓰임이나 살펴보자면 이런식으로 쓰는 것도 가능하다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 당연히 myValue 는 sum 으로 작동하고 myValue2 는 multi 로 작동한다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 마지막으로 함수 안에서 함수를 정의하는 것도 가능하다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre&gt;&lt;textarea name=&quot;code&quot; class=&quot;brush:swift;&quot;&gt;func myFunc(x:Bool) -&amp;gt; ( (Int, Int) -&amp;gt; Int)
{
    func sum(x:Int, y:Int) -&amp;gt; (Int)
    {
        return x+y
    }
    func multi(x:Int, y:Int) -&amp;gt; (Int)
    {
        return x*y
    }

    return x ? sum : multi
}

var myValue = myFunc(true)
var myValue2 = myFunc(false)
&lt;/textarea&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp; 결과는 함수를 반환하는 형태에서 쓰인것과 동일하다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; Objective-C 에서 신나게 블럭코딩이라고 쓰고 있었는데 아무래도 역시 새로나온 언어는 새로나온 건가 보다...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <category>function</category>
      <category>Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/141</guid>
      <comments>https://developers.tistory.com/141#entry141comment</comments>
      <pubDate>Mon, 25 May 2015 23:00:59 +0900</pubDate>
    </item>
    <item>
      <title>Dictionary</title>
      <link>https://developers.tistory.com/140</link>
      <description>&lt;p&gt;&amp;nbsp; Array 와 함께 가장 많이 쓰는 Dictionary&lt;/p&gt;&lt;p&gt;&amp;nbsp; Set 이라는 것도 있는데 이건 Objective-C 시절 부터도 그다지 많이 쓰진 않았던 터라..(사실 잘 모른다는게 젤 큰 이유지만..) 따로 한번 보고 일단 Dictionary는&lt;/p&gt;&lt;p&gt;&amp;nbsp; 1. 선언 - Array 처럼 뭐 여러가지 형태가 있는데 제일 맘에 드는 형태가&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerDict : [Int : String] = [:]&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이런식으로 생긴게 눈에도 잘 들어오는 것 같고 깔끔해 보인다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 앞서 Array 때도 그랬듯이 기본적으로 var 로 선언 하면 mutable 이다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 2. 값 설정은&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerDict[1] = &quot;A&quot;&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerDict[3] = &quot;B&quot;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 처럼 가능하다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 3. 설정값을 업데이트 하는 것도 있는데&lt;/p&gt;&lt;p&gt;







&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; if&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; stringValue = &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;integerDict&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;updateValue&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;&quot;newValue&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;, forKey: &lt;/span&gt;&lt;span class=&quot;s6&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; 위 처럼 사용할 경우 기존에 integerDict의 키가&amp;nbsp;1이었던 값이 return 되고 새로운 값이 설정된다&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; 4. 키 값을 따로 뽑아 오는 경우&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; let&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; integerKeys = [&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;integerDict&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; 이처럼 가능하고&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; 물론&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; stringValues = [&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;integerDict&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 이렇게 값만 가져올 수도 있다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&amp;nbsp; 그 외에는 일반적으로 예전과 크게 차이를 보이는건 안보이는듯...&lt;/span&gt;&lt;/p&gt;





</description>
      <category>나름 프로그래밍?/Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/140</guid>
      <comments>https://developers.tistory.com/140#entry140comment</comments>
      <pubDate>Tue, 19 May 2015 22:04:07 +0900</pubDate>
    </item>
    <item>
      <title>Array</title>
      <link>https://developers.tistory.com/139</link>
      <description>&lt;p&gt;&amp;nbsp; 이제 핵심인 Array&lt;/p&gt;&lt;p&gt;&amp;nbsp; 1. 기본적인 선언&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerArray = Array&amp;lt;Int&amp;gt;()&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerArray : [Int] = []&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerArray = [Int](count: 3, repeatedValue: 0]&lt;/p&gt;&lt;p&gt;&amp;nbsp; 등등 여러가지 형태가 존재하던데.. 쓰면서 손에 익는걸 쓰면 될듯???(여러가지 샘플이나 몇개 참고해보고 나아 보이는걸...)&lt;/p&gt;&lt;p&gt;&amp;nbsp; 기본적으로 var 는 변수를 뜻하고 let 은 상수를 뜻하니 따로 mutable 로 선언했던 예전과 달리 이렇게 선언해 놓으면 추가 삭제가 가능하다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 2. 값 추가&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerArray.append(3)&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerArray += [3]&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerArray += [4,5]&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이런식으로 추가도 가능하다&lt;/p&gt;&lt;p&gt;&amp;nbsp; 3. 기본적으로 mutable 에서 가능했던 replace 도&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerArray[2] = 3&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이런식으로 가능하다(index 벗어나는건 안되더라..)&lt;/p&gt;&lt;p&gt;&amp;nbsp; 더불어 범위도 지정 가능하다&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerArray[2...4] = [2,3,4]&lt;/p&gt;&lt;p&gt;&amp;nbsp; 4. 특정 인덱스 추가 혹은 삭제도 가능하다&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;integerArray&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;, atIndex: &lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;)&lt;/span&gt;&lt;/p&gt;








&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; integerArray&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;removeAtIndex&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p class=&quot;p3&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; integerArray&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;removeRange&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot;&gt;&lt;span class=&quot;s5&quot;&gt;&amp;nbsp; 5. for문으로 값들을 탐색하거나 enumerate 가 사용가능하다 특이한것은&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; for&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; (index, value) &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;integerArray&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s5&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;index &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;) : value &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&quot;&lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot;&gt;&lt;span class=&quot;s5&quot;&gt;










&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; 이런식으로 tuple 형태로 받아올 수도 있다&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/139</guid>
      <comments>https://developers.tistory.com/139#entry139comment</comments>
      <pubDate>Tue, 19 May 2015 00:01:37 +0900</pubDate>
    </item>
    <item>
      <title>optional</title>
      <link>https://developers.tistory.com/138</link>
      <description>&lt;p&gt;&amp;nbsp; Swift 에서는 nil은 '값이 없다'라는 의미로 사용한다고 한다(?)&lt;/p&gt;&lt;p&gt;&amp;nbsp; 예전처럼&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerValue : Int&lt;/p&gt;&lt;p&gt;&amp;nbsp; 라는 값이 있다고 하면&lt;/p&gt;&lt;p&gt;&amp;nbsp; if integerValue {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ...&lt;/p&gt;&lt;p&gt;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이런식으로 (int 가지고 이러진 않았지만) 값이 있나 검사했다면 이제는 Int 라고 선언된 변수에는 nil 이 들어갈 수 없기에 에러를 띄운다&lt;/p&gt;&lt;p&gt;&amp;nbsp; nil을 위해서는 optional 로 선언되어야 하고&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerValue : Int?&lt;/p&gt;&lt;p&gt;&amp;nbsp; 처럼 마지막에 ? 를 붙이면 된다.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 그렇다면 optional 은 nil 이 될 수&amp;nbsp;있다고 &amp;nbsp;했으니 값을 가져와 사용할때는 nil 인지 여부를 체크해야 된다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerValue : Int?&lt;/p&gt;&lt;p&gt;&amp;nbsp; var integerValue2 : Int&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 이렇게 있다고 한다면&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerValue2 = integerValue1&lt;/p&gt;&lt;p&gt;&amp;nbsp; 과 같이 optional이 optional로 선언되지 않은 변수에 바로 들어가지 못한다 이럴땐&lt;/p&gt;&lt;p&gt;&amp;nbsp; integerValue2 = integerValue1!&lt;/p&gt;&lt;p&gt;&amp;nbsp; 처럼 !(forced unwrapping operator란다..)를 붙여주면서 여기엔 값이 명확히 있다! 라고 알려주면 된다 말마따나 이전 버젼에서 nil 때문에 뻑하면 튕기던 문제를 잡는다는 것 같다... 말마따나 변수를 만들때마다 optional 로 줄지를 결정해주는 과정이 필요할듯&lt;/p&gt;&lt;p&gt;&amp;nbsp; 그리고 optional 일때 체크를 매번 해서 가져오는 번거로움을 조금이라도 피하라는 장치는 있다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;s1&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt; integerValue1 : &lt;/span&gt;&lt;span class=&quot;s3&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;s2&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;? = &lt;/span&gt;&lt;span class=&quot;s4&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;33&lt;/span&gt;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; if&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; integerValue2 = &lt;/span&gt;&lt;span class=&quot;s5&quot;&gt;integerValue1&lt;/span&gt;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; {&lt;/span&gt;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s6&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s7&quot;&gt;&quot;integer &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;integerValue2&lt;/span&gt;&lt;span class=&quot;s7&quot;&gt;)&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&amp;nbsp; 이와 같이 if let으로 optional 값을 체크해서 변수로 담아올 수 있다 그리고 Optional Chaining 이라는 것도 두어 여러차례 검사해서 집어넣는 것도 약간 간소화를 시켜 놓았는데&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; 사실 지금 단계에선 봐도 이해가 잘 안되서&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/OptionalChaining.html&lt;/p&gt;&lt;p&gt;&amp;nbsp; 링크로...........&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/138</guid>
      <comments>https://developers.tistory.com/138#entry138comment</comments>
      <pubDate>Mon, 11 May 2015 23:14:52 +0900</pubDate>
    </item>
    <item>
      <title>Range Operator</title>
      <link>https://developers.tistory.com/137</link>
      <description>&lt;p&gt;&amp;nbsp; 1. Close Range Operator&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;for문 같은거 쓸때 ... 붙이는 것 처럼 영역을 지정해 줄수 있는 연산자..&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;1...5 -&amp;gt; 1,2,3,4,5&lt;/p&gt;&lt;p&gt;&amp;nbsp; 2. Half Open Range Operator&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;1..&amp;lt;5 -&amp;gt; 1,2,3,4&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;간단하게 범위를 지정할때 편할듯?&lt;/p&gt;</description>
      <category>나름 프로그래밍?/Swift</category>
      <author>-Dong-</author>
      <guid isPermaLink="true">https://developers.tistory.com/137</guid>
      <comments>https://developers.tistory.com/137#entry137comment</comments>
      <pubDate>Thu, 7 May 2015 16:30:26 +0900</pubDate>
    </item>
  </channel>
</rss>