본문 바로가기
[ios] NSError** 에 대한 nullable, nonnull warning 처리 [ios] NSError** 에 대한 nullable, nonnull warning 처리 원래는 제대로 NSError** 에 대해서도 nullability 체크를 해주려면, 아래와 같이 바뀌어야 한다.(NSError**) error => (NSError* __nullable * __nullable) error 그러나 가독성이나 코드 유지 측면에서 봤을 때, 너무 좋지 않다.차라리 필요한 곳에만 nullability 를 넣고, warning 을 생성하지 않는 것이 방법일 수도 있다.이 경우에는 이를 넣어주면 된다. #pragma clang diagnostic ignored "-Wnullability-completeness" diagnostic ignored, nonnull, nonnull warning 처.. 2017. 11. 8.
[ios] Nullable & NonNull annotation [ios] Nullable & NonNull annotation -안드로이드에 보면 @Nullable, @NonNull 이라는 annotation 이 있어 API 사용에 대한 혜안을 주기 편리하다. -iOS 에도 있을까? -있다._Nullable 과 _Nonnull 이 그것이다. --(NSString* _Nullable)informationWithId:(NSString* _Nonnull)id; 위와 같은 문법으로 사용하면 된다. -_Nullable 과 _Nonnull 대신 nullable 과 nonnull 로 사용해도 된다.대신 이 경우에는 괄호의 처음에 온다.-(nullable NSString*)informationWithId:(nonnull NSString*)id; -property 에도 nullab.. 2017. 10. 30.
[도서 목차 정리] Kotlin in action [도서 목차 정리] Kotlin in action Kotlin in action 을 공부하면서 정리한 내용입니다.Java 를 어느 정도 이해하고 숙달한 사람들이 이해하기 좋습니다.Java 와 동일하거나 너무 당연한 기본적인 내용은 정리하지 않았습니다. Kotlin 소개 - Kotlin : what and why Kotlin 기초 #1 - Chap2. Kotlin basics Kotlin 기초 #2 - Chap2. Kotlin basics 함수 정의하고 호출하기 #1 - Chap 3. Defining and calling functions 함수 정의하고 호출하기 #2 클래스, objects, 그리고 인터페이스 #1 - Chap4. Classes, objects, and interfaces 클래스, obje.. 2017. 9. 25.
[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] 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.
반응형