문자열 접근과 수정 문자열 인덱스 각 String값은 문자열에 각 Character의 위치에 해당하는 String.Index인 인덱스 타입을 가지고 있다. Swift 문자열은 정수값으로 인덱스를 생성할 수 없다. 문자열 범위를 벗어나면 런타임 에러가 발생한다. let hello = "Hello" hello[hello.startIndex] // H hello[hello.index(before: hello.endIndex)] // o hello[hello.index(after: hello.startIndex)] // e let index = hello.index(hello.startIndex, offsetBy: 3) hello[index] // l 삽입과 삭제 insert(_:at:) // 하나의 문자를 삽..
Swift에서 특정 문자열 제거 및 치환 하는법 replacingOccurrences(of:with:) String에서 대상 문자열을 다른 주어진 문자열로 대체되는 새 문자열로 반환하는 인스턴스 메서드 Declaration 선언 func replacingOccurrences( of target: String, with replacement: String ) -> String Parameter 매개변수 target: 바꿀 문자열 replacement: target 문자열을 치환할 문자열 사용 예시 var 정대만: String = "난 정대만 포기를 모르는 남자지." 정대만 = 정대만.replacingOccurrences(of: "모르는", with: "하는") print(정대만) // 난 정대만 포기를 하..
- Total
- Today
- Yesterday
- Swift
- 라이트모드
- dictionary
- swipe
- SwiftLint
- SwiftUI
- 웹뷰
- autolayout
- Observable
- gcd
- UIScrollView
- Android
- LazyHStack
- UITabBarController
- UIButton
- remote config
- NavigationLink
- 다크모드
- RxSwift
- Realtime Database
- subscript
- 문자열
- github
- Apple
- Java
- string
- ios
- WebView
- Alamofire
- Firebase
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |