본문 바로가기
[ios] Objective-C 와 Swift 동시에 사용하기 [ios] Objective-C 와 Swift 동시에 사용하기 https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html Swift Code 에서 Objective-C 코드 사용하기-Swift Code 에서 Objective-C 코드를 쓰려면, Objective-C bridging header 가 필요하다.Xocde 는 Objective-C app 에서 Swift file 을 추가할 때, 혹은 그 반대일 때 이를 쉽게 만들 수 있도록 도와준다. 이 과정을 통해 만들어진 header 파일은 [productModuleName]-Bridging-Header.h 파일명을 갖는다. 이.. 2017. 12. 2.
[Effective Objective-C] #42 performSelector 메서드군보다는 GCD 를 사용하라 [Effective Objective-C] #42 performSelector 메서드군보다는 GCD 를 사용하라 출처 : Effective Objective-C -performSelector 는 다음과 같이 사용한다.- (id)performSelector:(SEL)selector 이 메서드를 통해 선택자를 호출하는 것과 그냥 선택자를 직접 호출하는 것은 기능적으로 같은 것이다. 즉, 아래 두 코드는 같은 내용이다.[object performSelector:@selector(selectorName)];[object selectorName]; -이 메서드들의 진정한 능력은 선택자를 실행 시간에 결정할 수 있는 데서 비롯된다.이러한 동적 바인딩의 가장 큰 능력은 다음과 같은 일을 할 수 있다는 것이다.SEL .. 2017. 10. 7.
[Kotlin Tutorial] Generics - Chap9. Generics 참조 : Kotlin in action 9.1. Generic type parameters -Java 와 기본적으로 generic 사용법은 동일하다. -Type Inference 는 가능하지만 명시적으로 써야 하는 케이스도 있다.val authors = listOf(“Dmitry”, “Svetlana”) // type inference 가능 val readers : MutableList = mutableListOf() // type inference 불가능, 명시적 선언val readers = mutableListOf() -Kotlin 에서는 raw type generic 을 사용할 수 없다. ( Java 로 치자면 그냥 List ) 9.1.1. Generic functions and properties.. 2017. 9. 5.
[Kotlin Tutorial] Kotlin 의 Type system #2 [Kotlin Tutorial] Kotlin 의 Type system #2 참조 : Kotlin in action 6.2. Primitive and other basic types 6.2.1. Primitive types: Int, Boolean, and more -Kotlin 은 primitive type 과 wrapper type 을 구분하지 않는다. -그렇다면 Int 가 object 라면 Kotlin 은 모든 primitive type 을 실제로 object 로 만드는가?당연히 그렇게 안 했다.compiler 가 대부분의 Int type 을 Java 의 primitive type 으로 변형시킨다.generic, collection 등은 원래 Java 의 Integer 형태만 담을 수 있으므로 이 경.. 2017. 8. 22.
[Kotlin Tutorial] Kotlin 의 Type system - Chap6. The Kotlin type system [Kotlin Tutorial] Kotlin 의 Type system - Chap6. The Kotlin type system 출처 : Kotlin in action 6.1. Nullability 6.1.1. Nullable types -Kotlin 은 nullable types 를 지원한다.nullable type 이라는 것은 어떤 variable 이 null 을 가질 수 있는지를 명시하는 것이다. -nullable 하지 않은 곳에 null 을 넣으면 compile error 가 난다.기본 type 은 nullable 하지 않으며, nullable 을 만드려면 type 뒤에 ? 를 붙여주면 된다.어떤 타입이든 뒤에 ? 를 붙여줄 수 있다.fun strLenSafe(s: String?) = … 6.1.2.. 2017. 8. 18.
[Effective Java] 인터페이스를 사용해서 확장 가능한 enum 을 만들자. [Effective Java] 인터페이스를 사용해서 확장 가능한 enum 을 만들자. - 대개의 경우 enum 의 확장은 좋지 않은 생각으로 밝혀졌다. - 확장 가능한 enum 타입을 사용해야 할 경우가 최소한 한 가지가 있는데, 작동 코드(operation code) 또는 opcode 라고 하는 것으로 특정 머신의 작동을 나타내는 요소들을 갖는 enum 타입이다. - 인터페이스를 구현한 enum 에 generic 을 설정할 경우는 아래와 같이 할 수 있다. bounded wild card Class opSet // class 객체가 enum 과 Operation 서브 타입 모두임을 나타냄. unbounded wild card Collection 2016. 12. 29.
[Effective Java] 제네릭 타입을 애용하자. [Effective Java] 제네릭 타입을 애용하자. - 클래스를 제네릭화 하는 방법. - 1. 클래스 선언부에 하나 이상의 타입 매개변수를 추가. - 2. 코드 안에 나오는 모든 Object 타입을 그것에 맞는 타입 매개변수로 변경한 후 컴파일. new E[ size ] 와 같은 부분에서 보통 에러가 난다. 이를 피해가는 방법 1. E[] elements = (E[]) new Object[ size ]; // 타입 안전하진 않다. 이를 피해가는 방법 2. Object[] elements = new Object[ size ]; // 사용하는 부분에서 casting 이 필요하다.. scalar 타입보다 배열 타입에 대한 unchecked 캐스트 경고를 억제하는 것이 더 위험하므로, 2번 방법이 더 적합해.. 2016. 11. 29.
[Java] Generic explicit type parameter 이야기 [Java] Generic explicit type parameter 이야기 참조 : http://shanhe.me/2011/09/11/explicit-type-parameters-for-generic-methods 참조 : http://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html - 자바 7, 8 로 version up 이 되면서 조금 더 강화된 compiler 로 type inference 도 강화되어 explicit type parameter 를 지정할 일이 거의 없다. -public static Map toHashMap(Map map) {return new HashMap(null == map ? Collections.em.. 2016. 10. 18.
[android] RecyclerView 에 대한 맛보기 이야기 [android] RecyclerView 에 대한 맛보기 이야기 참조 : https://www.bignerdranch.com/blog/recyclerview-part-1-fundamentals-for-listview-experts/ -RecyclerView 는 ListView 에 대비하여 다음과 같은 일들을 하지 않는다. 1. List Item 들을 화면에 배치하지 않는다. -> LayoutManager 가 이 일을 맡아서 한다.2. View 들의 animation 을 관장하지 않는다. -> ItemAnimator 가 이 일을 맡아서 한다.3. Scrolling 외의 touch event 를 관장하지 않는다. -RecyclerView 는 가급적 listview 본연의 일에만 집중하고 view, anima.. 2016. 9. 23.
반응형