본문 바로가기
[Kotlin Tutorial] Operator overload 와 convention #2 [Kotlin Tutorial] Operator overload 와 convention #2 출처 : Kotlin in action 7.3. Destructuring declarations and component functions -val p = Point(10, 20)val (x, y) = p // destructuringprintln(x)println(y) -destructuring 도 convention 을 사용한다.componentN 이 호출된다. ( N 은 숫자 )val (a, b) = p // val a = p.component1()// val b = p.component2() -data class 는 compiler 가 primaryConstructor 에 정의된 모든 property 에 .. 2017. 8. 29.
[Kotlin Tutorial] 람다로 프로그래밍 하기 - Chap5. Programming with Lambdas [Kotlin Tutorial] 람다로 프로그래밍 하기 - Chap5. Programming with Lambdas 참조 : Kotlin in Action 5.1. Lambda expressions and member references 5.1.1. Introduction to lambdas : blocks of code as function parameters 5.1.2. Lambdas and collections -val people = listOf(Person(“Alice”, 29), Person(“Bob”, 31))println( people.maxBy{ it.age } ) // function 을 argument 로 받는다. { } 는 lambda syntax lambda 가 단순 functio.. 2017. 8. 16.
[Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #2 [Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #2 참조 : Kotlin in Action 4.3. Compiler-generated methods: Data classes and Class delegation 4.3.1. Universal object methods -Java 에서 == 는 primitive 나 object 의 reference 를 비교하는 것.Kotlin 에서는 == 가 기본비교이다. equals 를 호출해서 비교한다.그럼 Java 에서의 == 는? === 로 대체된다. 4.3.2. Data classes: autogenerated implementations of universal methods -data class Client(val name: Stri.. 2017. 8. 14.
[Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #1 - Chap4. Classes, objects, and interfaces [Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #1 - Chap4. Classes, objects, and interfaces 참조 : Kotlin in Action 4.1. Defining class hierarchies 4.1.1. Interface in Kotlin -Kotlin 의 interface 는 Java8 과 비슷하다.abstract method 를 가질수도 있고, Java8의 default method 도 가질 수 있다. ( Java8 과는 다르게 default keyword 는 필요없다 )단, state 는 여전히 가질 수 없다. ( 실제 variable ) -Kotlin 에서 interface 정의는 아래와 같다.interface Clickable{ fun.. 2017. 8. 11.
[Kotlin Tutorial] 함수 정의하고 호출하기 #2 [Kotlin Tutorial] 함수 정의하고 호출하기 #2 참조 : Kotlin in Action 3.4. Working with collections: Varargs, Infix calls, and Library support 3.4.1. Extending the Java collections API -val strings: List = listOf(“first”, “second”, “thrid”)strings.last() val numbers: Collection = setOf(1, 14, 2)numbers.max() last 와 max 는 extension 이다.이 외에도 많이 있으니 IDE 의 code completion 을 잘 활용해보시라~ 3.4.2. Varargs: functions tha.. 2017. 8. 3.
[Effective Objective-C] #6 프로퍼티를 이해하라 [Effective Objective-C] #6 프로퍼티를 이해하라 출처 : Effective Objective-C -프로퍼티는 객체가 포함한 데이터를 캡슐화하는 방법을 제공하는 Objective-C 의 기능이다. -인스턴스 변수는 항상 접근자 메서드(accessor method)를 통해 접근한다.Objective-C 2.0 배포판에 프로퍼티라는 기능으로 포함되었다.이 기능으로 개발자는 접근자 메서드들을 자동으로 생성하라고 컴파일러에 알려줄 수 있다.프로퍼티는 점(.) 문법이라는 새로운 방법을 제공한다.점 문법 덕분에 클래스에 저장된 데이터에 접근하는 방법이 좀 덜 장황해졌다. -@interface EOCPerson : NSObject{@public NSString *_firstName; NSString.. 2017. 7. 27.
[android] ObjectAnimator 이야기 [android] ObjectAnimator 이야기 http://developer.android.com/reference/android/animation/ObjectAnimator.htmlhttp://developer.android.com/reference/android/animation/ValueAnimator.html -API Level 11 부터 사용 가능하다. -ValueAnimator 의 subclass 로 target object 의 property 에 대한 animation 을 할 수 있다.생성자는 target object 와 target property 이름을 받아들인다.target property 에 assign 되는 것들은 내부적으로 get/set function 이 있어야 한다. -O.. 2017. 7. 22.
[iOS Study] 코어 데이터 [iOS Study] 코어 데이터 출처 : 아론 힐리가스의 iOS 프로그래밍 -데이터를 로컬에 저장하는 방법은 “아카이빙” 또는 “코어 데이터” 를 사용한다. -아카이빙의 가장 큰 결점은 전부 다냐 아무것도 아니냐는 특성에 있다.아카이브 안의 내용에 접근하려면 전체 파일을 언아카이브해야 한다.변경사항을 저장하려면 전체 파일을 다시 쓰기 해야 한다.반면 코어 데이터(Core Data)는 저장된 객체의 일부만 가져올 수 있다.그리고 어떤 객체를 변경한다면 파일의 해당 부분만 갱신할 수 있다.이러한 점진적 가져오기, 업데이트, 삭제, 삽입은 파일시스템과 메모리 사이를 오가는 많은 모델 객체를 가지는 경우 앱의 급격한 성능 향상을 가져올 수 있다. -코어 데이터는 객체-관계형 매핑 ( object-relatio.. 2016. 3. 25.
[iOS Study] 자동 회전, 팝오버 컨트롤러, 모달 뷰 컨트롤러 [iOS Study] 자동 회전, 팝오버 컨트롤러, 모달 뷰 컨트롤러 출처 : 아론 힐리가스의 iOS 프로그래밍 -이 장에서는 아래의 주제를 다룬다. 장치 의존적인 코드를 작성하는 방법과 장치의 종류에 따라 테스트하는 방법 회전, 팝오버 컨트롤러, 모달 뷰 컨트롤러 -iOS 에서는 방향을 장치방향 (device orientation) 과 인터페이스 방향(interface orientation) 두 가지로 구분한다. -장치 방향은 장치 표면이나 후면에서 정방향, 뒤집힌 상태, 왼쪽 회전, 오른쪽 회전인지에 따른 물리적 방향을 나타낸다.UIDevice 클래스의 orientation 프로퍼티를 통해 장치의 방향에 접근할 수 있다. -인터페이스 방향은 실행 중인 프로그램의 프로퍼티이다. UIInterfaceOr.. 2016. 3. 5.
반응형