본문 바로가기
[android] background work(AlarmManager) 수행에 대한 이야기 [android] background work(AlarmManager) 수행에 대한 이야기 https://plus.google.com/+AndroidDevelopers/posts/GdNrQciPwqo -구버전 안드로이드에서는 background work 를 위해서 보통 AlarmManager 를 사용했다.AlarmManager 를 사용하면 앱이 foreground 가 아닌 상황에서도 미래 특정 시점에 어떤 일을 하도록 scheduling 을 할 수 있다. -60초 이내에 무언가를 수행하게 하고 싶다면 AlarmManager 는 best choice 가 아닐 수 있다.이 때는 Handler 를 이용해보도록 하자. -API 21+ (5.0 LOS) 부터는 setAlrmClock() API 를 통해서 user.. 2019. 1. 27.
[도서 정리] Android Development with Kotlin - Classes and Objects Android Development with Kotlin - Classes and Objects 이 정리글은 Kotlin in Action 책을 보고 실무에 Kotlin 을 사용하던 사람이 몰랐던 내용이나 remind 하고 싶은 내용을 위주로 정리한 글입니다.제대로 내용을 파악하시려면 책을 구매해서 읽어보세욤~ -Kotlin 은 write-only property 는 지원하지 않는다. -Primary constructor 가 정의되어 있다면 secondary constructor 에서 반드시 불러줘야 한다. -Primary constructor 가 없는데 parent 가 non-empty constructor 를 가지고 있다면 그 녀석을 호출해주어야 한다. -class Fruit(name:String) .. 2018. 12. 13.
[Kotlin] 장점, 단점, 그리고 아쉬운 점 이야기 [Kotlin] 장점, 단점, 그리고 아쉬운 점 이야기 https://medium.com/keepsafe-engineering/lessons-from-converting-an-app-to-100-kotlin-68984a05dcb6https://medium.com/keepsafe-engineering/kotlin-the-good-the-bad-and-the-ugly-bf5f09b87e6f -위 링크의 글을 쓴 필자는 마켓에 출시된 Java 로 되어 있는 앱을 Kotlin 으로 전환했다.많은 사람들이 Kotlin lib 때문에 dex method limit 이 걸릴 것을 걱정하지만,실제 converting 후 proguard 적용시 method count 는 10% 줄어들고, code line 은 30% 줄.. 2018. 1. 15.
[Objective-C] Foundation 프레임워크의 중요 클래스 - NSData, NSArray, NSSet [Objective-C] Foundation 프레임워크의 중요 클래스 - NSData, NSArray 9.3. 데이터 클래스 * 9.3.1. NSData -NSData 는 임의의 바이트 배열을 객체로 다루기 위한 랩퍼(wrapper) 이다. -일반적인 C 배열을 사용할 때와 비교했을 때의 장점은 객체로 추상화해서 다룰 수 있는 점,메모리 관리가 쉬운 점, Cocoa API 에서 바이트 배열을 다루는 표준이라는 점. -NSData 인터페이스는 한 번 작성되면 데이터 내용을 변경할 수 없다.데이터 내용을 나중에 변경하려면 NSMutableData 클래스를 사용해야 한다. -NSData 는 클래스 클래스터로 제공되므로 NSData 가 인스턴스의 직접 클래스가 아니라는 점, 일반 방법으로는 서브 클래스를 작성할.. 2017. 12. 31.
[Effective Objective-C] #48 반복문에는 블록 열거를 사용하라 [Effective Objective-C] #48 반복문에는 블록 열거를 사용하라 출처 : Effective Objective-C -최신 오브젝티브-C 에는 열거하는 방법이 많다.표준 C 반복문부터 오브젝티브-C 1.0의 NSEnumerator, 그리고 오브젝티브-2.0 의 빠른 열거자(fast enumeration)도 있다. for 루프 -컬렉션을 열거하는 첫 번째 메서드는 훌륭하고 오래된 방법인 for 루프다.NSArray *anArray = …;for (int i=0; i < anArray.count; i++){ id object = anArray[i]; // do something} 이 방법은 쓸만하지만 사전이나 집합을 반복하면 훨씬 복잡해진다.NSDictionary *aDictionary = ….. 2017. 10. 15.
[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] 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] Operator overload 와 convention #1 - Chap7. Operator overloading and other conventions [Kotlin Tutorial] Operator overload 와 convention #1 - Chap7. Operator overloading and other conventions 참조 : Kotlin in action -Java 에는 특정 class 에 결속되어 있는 언어적 기능이 있다.예를 들어 Iterable 를 구현하면 for loop 에서 쓸 수 있고, AutoCloseable 을 구현하면 try-with-resources 에서 사용할 수 있다. Kotlin 도 비슷한 것들이 있다.그러나 specific type 에 결속된 것이 아니라 specific name 에 결속되는 기능들이 있다.예를 들어 plus 라는 이름으로 class 에 function 을 추가하면, + operator 를 해.. 2017. 8. 24.
반응형