TIL32 ✨

YaR Lab·2023년 6월 6일
1

TIL✨

목록 보기
22/135
post-thumbnail

23.06.06

https://developer.apple.com/documentation/swift

step2 변수네이밍

  • ExpressionParser: ExpressionParser는 수식을 구문 분석하여 평가하는 역할을 담당하는 클래스나 함수입니다. 주어진 수식을 토큰으로 분리하고, 토큰의 순서와 구조를 분석하여 수식을 해석하고 계산합니다.

  • parse: parse는 주어진 입력을 해석하고 필요한 정보를 추출하는 과정을 말합니다. 주로 구문 분석을 수행하여 문장이나 표현식의 의미를 파악하고, 해당 내용을 데이터 구조로 변환하는 작업을 의미합니다.

  • componentsByOperators: componentsByOperators는 주어진 문자열을 특정 연산자를 기준으로 분리하여 구성 요소들로 반환하는 함수입니다. 주로 수식을 분할하거나 토큰화할 때 사용됩니다. 예를 들어, "3+42"라는 문자열을 "+" 연산자를 기준으로 분리하면 ["3", "42"]라는 배열이 반환됩니다.

  • Formula: Formula는 수식이나 계산식을 나타내는 것을 의미합니다. 일반적으로 수학적인 식이나 프로그래밍에서의 계산식을 나타내는 용어로 사용됩니다. Formula는 수식을 해석하고 계산하기 위해 필요한 규칙이나 알고리즘을 포함할 수 있습니다.

split

스위프트 표준 라이브러리에 속해 있음
-separator
분할자로 문자열을 분할해서 Substring배열을 반환

let str = "Hello World"
let arr = str.split(separator: " ")
print(type(of: arr))//Array<Substring>
print(arr)//["Hello", "World"]

-maxSplits
문자열을 자르는 횟수, Int 타입

let str = "He llo Worl d"
let arr = str.split(separator: " ", maxSplits: 1)
print(arr)//["He", "llo Worl d"]

-omittingEmptySubsequences
false일때 빈 문자열(subString)을 제외하고 결과를 반환
default는 true이다

let str = "hello,,,,,World"
let arr = str.split(separator: ",", omittingEmptySubsequences: false)
print(arr) //["hello", "", "", "", "", "World"]

components

Foundation라이브러리를 import해야함
-seperatedBy
분할자로 문자열을 분할해서 String배열을 반환

import Foundation
let str = "he ll o"
let arr = str.components(separatedBy: " ")
print(type(of: arr)) //Array<String>
print(arr) //["he", "ll", "o"]

LLDB 문제

  • ViewController.swift 파일의 23번째 줄에 브레이크 포인트를 설정하려면 입력해야 하는 LLDB 명령어는?
br -s -f ViewController.swift -l 23
  • changeTextColor라는 심볼에 브레이크 포인트를 설정하기 위해 입력해야 하는 LLDB 명령어는?
b -n changeTextColor
  • LLDB의 특정 명령어의 별칭을 설정해줄 수 있는 명령어는 무엇일까요?
command alias brs breakpoint set 
  • Breakpoint Navigator를 통해 titleLabeltext"두 번째 뷰 컨트롤러!"인 경우에만 작동을 일시정지하고 titleLabeltext를 출력하는 액션을 실행하도록 설정해보세요
# breakpoint 찍은 후
# breakpoint navigator에서
# condition에 titleLabel.text == "두 번째 뷰 컨트롤러!"
# Action에 Debugger Command에
# po print(titleLabel.text)
  • 오류(Error) 혹은 익셉션(Exception)이 발생한 경우 프로세스의 동작을 멈추도록 하는 방법에 대해 알아봅시다
# breakpoint navigator에서
# Exception Breakpoint
# 프로그램이 실행되는 동안 에러가 발생했을때 break해줌
  • View Controller의 뷰 위에는 사용자 눈에 보이지 않는 뷰가 있습니다. 이 뷰의 오토레이아웃 제약을 확인해서 알려주세요
  • 디버그 모드로 실행중인 상태에서 사용자 눈에 보이지 않는 뷰의 색상을 분홍색으로 변겅해보세요

  • LLDB의 v, po, p 명령어의 차이에 대해 알아봅시다

  • 두 번째 뷰 컨트롤러의 뷰가 화면에 표시된 상태에서, 두 번째 뷰 컨트롤러 까지의 메모리 그래프를 캡쳐해보세요

while let

    mutating func result() throws -> Double {
        guard var result = operands.dequeue() else {
            throw OperationError.operandNotEnoughError
        }

        while let nextOperand = operands.dequeue() {
            guard let operatorElement = operators.dequeue() else {
                throw OperationError.operatorNotEnoughError
            }
            
            result = try operatorElement.calculate(lhs: result, rhs: nextOperand)
        }
        
        return result
    }

separatedBy: CharacterSet((charactersIn: operators))

append contentsOf

https://developer.apple.com/documentation/swift/array/append(contentsof:)-21slv

if throw

throw하고 멈춤

1개의 댓글

comment-user-thumbnail
2023년 6월 7일

잘봤습니다!!

답글 달기