본문 바로가기
[ios] block typedef 방법 & param 기입 방법 [ios] block typedef 방법 & param 기입 방법 -block 의 typedef 는 문법이 딱 와닿지 않는다. -typedef 를 할 때는 block 을 함수 포인터라고 생각하고 정의하면 쉽다. -Syntax :typedef returnType (^blockName)(params); Example :typdef void (^MyBlock)(UIView * _Nonnull view); -param 으로 쓸 때는 또 다른 형태가 된다. -Syntax :(returnType (^)(params)) paramName Example :-(void)doSomething:(void (^)(UIView * _Nonnull))block; block typedef, blockname, Example, Pa.. 2017. 12. 17.
[Kotlin Tutorial] Annotation 과 Reflection #2 [Kotlin Tutorial] Annotation 과 Reflection #2 참조 : Kotlin in action 10.2. Reflection: introspecting Kotlin objects at runtime -Kotlin 에서의 reflection 은 java.lang.reflect package 의 API 들과 kotlin.reflect package 의 API 들을 사용한다.Kotlin 의 reflection 은 Java 에 없는 nullable type 이나 properties 들의 접근을 가능하게 한다. -runtime lib 의 size 를 줄이기 위해, kotlin 의 reflection API 는 kotlin-reflect.jar 라는 별개의 jar 로 pakcage 되어 있.. 2017. 9. 12.
[Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection [Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection 참조 : Kotlin in action 10.1. Declaring and applying annotations. 10.1.1. Applying annotations -Annotation 사용법은 Java 와 동일하다. @ 를 prefix 로 하고 annotation name 을 써주면 된다. -@Deprecated 의 경우 Kotlin 은 Java 의 것에서 향상되었다.replaceWith parameter 가 추가되어, 새로운 version 의 API 에 연결될 수 있다.@Deprecated(“Use removeAt(index) instead.”, Rep.. 2017. 9. 7.
[Kotlin Tutorial] 한 차원 높은 함수 : 람다를 parameter 와 return value 로 - Chap8. Higher-order functions: lambdas as parameters and return values [Kotlin Tutorial] 한 차원 높은 함수 : 람다를 parameter 와 return value 로 - Chap8. Higher-order functions: lambdas as parameters and return values 참조 : Kotlin in action 8.1. Declaring higher-order functions -Higher-order function 이란 argument 와 return 으로 다른 function 을 갖는 것을 의미한다.Kotlin 에서는 function 이 lambda 나 function reference 로 표시된다. 8.1.1. Function types -val sum = { x:Int, y:Int -> x+y }val action = { pr.. 2017. 8. 31.
[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.
[android] AbstractAccountAuthenticator 에 대해 알아보자. [android] AbstractAccountAuthenticator 에 대해 알아보자. http://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator.html - 계정을 생성하기 위해서는 AbstractAccountAuthenticator 를 구현한 녀석을 가지고 있어야 한다. 또한 android.accounts.AccountAuthenticator action 을 처리하는 Service 도 구현해야 한다. 해당 service 에서는 Authenticator 의 getIBinder() 를 수행한 녀석을 IBinder 로 return 해주어야 한다. - AuthenticationService 는 다음과 같은 inte.. 2017. 7. 6.
[Effective Java] 가변인자(varargs)를 분별력 있게 사용하자. [Effective Java] 가변인자(varargs)를 분별력 있게 사용하자. - 1.5 이후에 사용 가능한 가변 인자. - 가변 인자만 받는 method 는 문제가 많다. 가장 심각한 것은 클라이언트가 인자를 주지 않고 메소드를 호출하면 Runtime Exception 이 나기 쉽다. ( 파라미터 없이 call 해도 args 값은 null 은 아니다. ) 또한 validity 를 명시적으로 추가해야 하며, 그 코드가 복잡해질 수 있다. - 가변 인자만 받는 method 대신 어떤 의미를 담은 하나의 인자를 더 받아서 처리하는 것이 좋다. - 성능이 중요한 상황에서 가변 인자를 사용하는 것을 주의하자. 가변 인자 메소드는 호출할 때마다 배열 생성과 초기화가 일어난다. 가변 인자의 유연함이 필요하다면 아.. 2017. 1. 17.
@NotNull annotation 의 장점 @NotNull annotation 의 장점 http://robaustin.wikidot.com/annotations-and-notnullhttps://www.jetbrains.com/idea/documentation/howto.html - Find Bugs 와 IntelliJ 는 null check annotation 을 지원한다. 코드 가독성 측면에서 좋지 않다는 이야기도 있지만, 그건 케바케. - function 의 param 에 null 이 들어오면 RuntimeException 을 던지도록 처리하는 것이 좋다.public void testMethodNotNull( @NotNull String param ){ // do sth.}만약 method 선언부에 @NotNull 을 선언하면, valida.. 2015. 6. 23.
[Android] save POJO to SharedPreferences [Android] save POJO to SharedPreferences POJO 를 SharedPreference 에 저장하려면 GSON 을 쓰는 방법도 괜찮다.POJO params 에 대한 encoding, decoding 등을 지원하므로.. Android, decoding, Encoding, field, GSON, member field, Param, POJO, SharedPreference, [Android] save POJO to SharedPreferences 2014. 3. 25.
반응형