- Today
- Total
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- deeplearning
- SWIFT
- Linux
- NVL
- SQL
- 연산자
- Upper
- grep
- trunc
- decode
- ReLU
- ios
- scheduledTimer
- r
- delegate
- MVC
- barplot
- tapply
- 명령어
- Observable
- swiftUI
- struct
- 시각화
- sigmoid
- Optional
- 딥러닝
- substr
- rxswift
- Python
- cocoapods
목록iOS (58)
iOS 개발 기록 블로그
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/b4jUR0/btrF4FnTmII/Hhg3NkcrzJaqkXb2sd6961/img.png)
지난 글들에서 익혔던 Networking과 API를 숙달하기 위해 비트코인 가격 조회하는 어플리케이션을 만들어볼 것이다. 지난 글 링크 iOS (Swift) GPS 받고 위도, 경도 받아서 날씨 API 데이터 받기 CoreLocation를 활용하여 위치 데이터를 받아볼 것이다. 먼저 해당 라이브러리를 import 해줘야 한다. import UIKit import CoreLocation class WeatherViewController: UIViewController { .. crazydeer.tistory.com URLSession을 사용하는 방법, HTTP Requests, JSON Parsing을 위한 JSON Decoder을 복습해볼 것이다. 흔히 거래되는 각국의 통화 별 비트코인의 가격을 조회해본..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/0HgYg/btrFXWYIu3Q/8rBG5tRDWDoVusRSu5hOw0/img.png)
CoreLocation를 활용하여 위치 데이터를 받아볼 것이다. 먼저 해당 라이브러리를 import 해줘야 한다. import UIKit import CoreLocation class WeatherViewController: UIViewController { @IBOutlet weak var conditionImageView: UIImageView! @IBOutlet weak var temperatureLabel: UILabel! @IBOutlet weak var cityLabel: UILabel! @IBOutlet weak var searchTextField: UITextField! var weatherManager = WeatherManager() let locationManager = CLLocat..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ccjOVU/btrFT066RmS/Tquvyq5ftEIsFWd5yi0C71/img.png)
이번 글에서는 MARK: - 키워드이 무엇인지, 코드 스니핏 (Code Snippet)이 무엇인지, 새로운 코드 스니핏을 생성하는 방법에 대해 알아보자. 우선 MARK: - 키워드에 대해서 보자 MARK: - 우선 사용하는 방법은 아래와 같다. 이렇게 쓰게 되면 스크립트 상에서도 선으로 섹션이 구분되어진다. 아래 버튼을 클릭하면 아래와 같이 섹션이 구분되고 클릭하면 스크립트 중에 해당하는 부분으로 바로 가게 된다. Code Snippet, 코드 스니핏 이미지로 한번에 설명하면 다음과 같다. 왼쪽에 아이콘 중 { } 이렇게 생긴 아이콘이 바로 코니 스니핏이다. 이걸 선택하면 아시다시피 다음과 같이 된다. 손쉽고 빠르게 코딩할 수 있도록 미리 만들어놓은 틀이라고 보면 된다. Create Code Snippe..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/Y6vt9/btrFSXWK2qC/lw8Mm5xdxLuhUQq7NyxIFk/img.png)
여러가지 예시와 함께 Swift의 extension에 대해 알아보자. 지하철의 노선과 역이 계속 추가되는 것처럼 일반적으로 앱도 계속해서 기능들이 덧붙여져서 확장한다. Extensions — The Swift Programming Language (Swift 5.7) Extensions Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you don’t have access to the original source code (known as retroactive modeling). Exten..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ecqBeS/btrFzOzCS9y/ysOJHYcECb4Wp5iis3DbL0/img.jpg)
파라미터 이름에는 internal 파라미터 이름과 external 파라미터 이름이 있다. internal은 그 함수 내부에서 쓰는 이름이고 external은 함수를 쓸 때 보여지는 이름이다. 내부, 외부 파라미터 func myFunc(name eman: Type) { print(eman) } 이 때 name이 external 파라미터이고 eman이 internal 파라미터다. myFunc(name: "cdeer") 여기서는 함수를 사용하는 부분이기 때문에 external parameter를 사용해야 한다. (name) 생략하는 경우 func myFunc(_ eman: Type) { print(eman) } 이렇게 언더바(_) 로 대체할 수 있고 이러면 사용할 때 파라미터명을 생략할 수 있다. myFunc..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bAkgFr/btrFyJSGDfH/km0v4cxAbaXw4ASrbo10IK/img.png)
iOS (Swift) JSON 디코딩(Decoding) func performRequest(urlString: String) { //1. Create a URL if let url = URL(string: urlString) { //2. Create a URLSession let session = URLSession(configuration: .default) //3. Giv.. crazydeer.tistory.com 지난 글에 이어 JSON을 정리하면서 MVC 디자인 패턴으로 바꾸고 그 과정에서 Computed Properties도 이해해보자. OpenWeatherAPI 문서가 제공하는 json 예시다. 여기에 id는 날씨 상태를 말하는데 이에 따라 아이콘이 변화하도록 해볼 것이다. Weather co..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/thMxZ/btrFAis2Vao/VLJ11Upg3faarovH04Pjo1/img.png)
func performRequest(urlString: String) { //1. Create a URL if let url = URL(string: urlString) { //2. Create a URLSession let session = URLSession(configuration: .default) //3. Give URLSession a task let task = session.dataTask(with: url) { data, response, error in if error != nil { print(error!) return// 에러가 있으면 스톱 } if let safeData = data { // safeData를 String 형태로 변환 } } //4. Start the task ta..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cONvf1/btrFoOGgv6V/kuM8MTKuhEz5x2RqJ1wjo1/img.png)
일반적인 함수의 형태는 아래와 같다. func functionName (param1: dataType, param2: dataType) -> dataType { return output } 특정 데이터가 입력되어 함수를 통과하면 데이터가 출력된다. 이 입력된 데이터들을 또 다른 함수를 통과하도록 할 수 있다. import UIKit import Foundation func calculator(n1: Int, n2: Int, operation: (Int, Int) -> Int) -> Int{ return operation(n1, n2) } func add(n1: Int, n2: Int) -> Int{ return n1 + n2 } print(calculator(n1: 2, n2: 3, operation: ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/7anxK/btrFkZBIGUW/KnHLmqiUucnoWJtz2KWDlK/img.png)
오픈 API를 사용하여 데이터를 받는 것을 Networking이라고 한다. 우리의 APP은 API를 통해 Web Server에 데이터를 요청한다. 우리가 필요한 데이터를 쿼리(Query)를 통해 요청(Request)한다. 웹 서버는 이 쿼리를 해석하고 필요로 하는 데이터를 보내준다. 이를 Response라고 한다. 이러한 일련의 프로세스를 'Networking'이라고 한다. Networking의 단계 Create a URL Create a URLSession Give URLSession a task Start the task WeatherManager.swift 파일 struct WeatherManager { let weatherURL = "https://api.openweathermap.org/data..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/rkzeS/btrFkZz1ZiO/npZkg4kK2ZKC8D6QlHATKk/img.png)
우선 지난 글에 이어서 웹 브라우저에서 받은 결과 중에 Temperature 값을 Celsius로 받는 방법을 알아보자. iOS (Swift) OpenWeather API 사용하는 법 API 란? 명령어, 함수, 프로토콜, 객체 등의 집합으로 많은 프로그래머들이 소프트웨어를 만들거나 외부 시스템과 상호작용하는 데에 사용할 수 있는 것이다. 많은 개발자들이 흔한 crazydeer.tistory.com Request 결과에서 temp가 Celsius로 나오도록 하기 간단하다. 문서를 뒤져보면 아래와 같은 부분을 찾을 수 있다. 파라미터를 추가해주면 간단하게 해결된다. Current weather data - OpenWeatherMap Access current weather data for any locat..