Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- map
- Observable
- RxCocoa
- 리팩토링
- ios
- swift documentation
- 클린 코드
- scrollview
- rxswift
- SWIFT
- combine
- 리펙토링
- HIG
- swiftUI
- UICollectionView
- UITextView
- Protocol
- clean architecture
- 스위프트
- uiscrollview
- Clean Code
- MVVM
- uitableview
- Xcode
- Human interface guide
- tableView
- collectionview
- ribs
- 애니메이션
- Refactoring
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] NSExpression 본문
* NSExpression 개념 전 NSPredicate 개념 확인
NSExpression
- 비교 조건에 사용되는 표현식

- NSExpression은 두개의 표현식을 기반으로 사용
- Constant Value
- Key path
Mapbox SDK 예시) NSExpression의 장점
- Mapbox라는 Map framework는 런타임 스타일링을 위하여 NSExpression을 사용
- NSExpression을 사용하면 사용자가 앱과 상호작용할 때 지도 모양의 모든 측면을 동적으로 수정이 가능
- 맵 쪽에서 geojson라는 파일을 받았을 때, 문자열을 NSExpression으로 사용하여 편리한 사용가능
- 특정 layer의 fontSize를 변경할 때 NSExpression 사용
- NSExpression(forConstantValue:)는 상수값 할당
- NSExpression(forKeyPath:)는 key값 할당 (mapbox에서 지정된 property들의 key값을 할당하면 그 값에 해당되는 value값 지정)
let feature = MGLPointFeature()
feature.coordinate = CLLocationCoordinate2D(latitude: 37.57442096285374, longitude: 126.88624804250178)
let source = MGLShapeSource(identifier: Map.FeatureID, features: features)
let layer = MGLSymbolStyleLayer(identifier: Map.FeatureID, source)
layer.textFontSize = NSExpression(forConstantValue: 12)

* 참고
- NSExpression: https://developer.apple.com/documentation/foundation/nsexpression
'iOS 응용 (swift)' 카테고리의 다른 글
Comments
