포스트

ByteCoin (1)

디자인은 생략이라, git clone 이후 부터 시작하겠다.

이번엔 특별히 git 협업 글을 생각해서 맥북과 맥미니 번갈아 가면서 코드를 작성해보려고 한다.

IBOutlet 만들기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import UIKit

class ViewController: UIViewController {

    
    
    @IBOutlet weak var bitcoinLabel: UILabel!
    
    @IBOutlet weak var currencyLabel: UILabel!
    
    @IBOutlet weak var currencyPicker: UIPickerView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


}

UIpickerView를 사용하기위해 protocol 채택하기.

채택하면 에러가 발생한다.

관렴 함수를 안써서 나오는 에러이다. 일단은 다음과 같이 작성해주자

1
2
3
4
5
6
7
func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }
    
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return CoinManager.currencyArray.count
    }

numberOfComponents : picker view에 사용된 컴포넌트의 개수를 가져온다.

API Request 구현하기

어떻게 json으로 가져오나 확인해보았다. https://rest.coinapi.io/v1/exchangerate/BTC/USD?apikey= 이런식으로 되었다.

다음과 같이 출력이 되는 것을 확인했다.

이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.