👨🏻‍💻iOS 공부

    [Swift] Swift 값 입력, 비교

    Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty.The rating for Alice's challenge is the triplet a = (a[0], a[1], a[2]), and the rating for Bob's challenge is the triplet b = (b[0], b[1], b[2]).The task is to find their comparison points by compar..

    [Swift] Array의 Sum 구하기

    Given an array of integers, find the sum of its elements.For example, if the array , , so return .Function DescriptionComplete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer.simpleArraySum has the following parameter(s):ar: an array of integersInput FormatThe first line contains an integer, , denoting the size of the array. The second ..

    [Swift] URLSession이란? (2)

    URLSession (2)response 받은 데이터를 object로 만들어 볼 것이다.블로그 내의 데이터를 받아와보려고 했으나, 구조가 많이 달라 우선 강의과 같은 조건으로 진행해보자. 우선 기존에 작성했던 것 처럼 urlComponents를 생성한다. let config = URLSessionConfiguration.defaultlet session = URLSession(configuration: config) // URLvar urlComponents = URLComponents(string: "https://itunes.apple.com/search?")!let mediaQuery = URLQueryItem(name: "media", value: "music")let entityQuery = U..

    [Swift] URLSession이란? (1)

    URLSession앱과 서버간에 데이터를 주고 받기 위해서는 HTTP를 이용했었다. 실제 iOS에서는 HTTP를 이용한 네트워킹을 어떻게 할까? 바로 URLSession을 활용하여 수행할 수 있다.URLSession은 URLSessionConfiguration을 통해 생성하게 된다. 또한 URLSession은 여러 개의 URLSessionTask를 만들 수 있다. 이를 통해 실제 서버와의 통신을 하며, Delegate를 통해 네트워크 중간 과정을 확인해볼 수 있다. 또한 URLSessionConfiguration을 통해 다음 세 가지 유형의 URL을 생성할 수 있다,.default : 기본 통신을 할 때 사용이 된다. (쿠키와 같은 저장 객체를 사용한다.).ephemeral : 쿠키나 캐시를 저장하지 않..

    [ETC_009] 구조체와 클래스

    구조체와 클래스구조체(struct)와 클래스(class)는 프로퍼티와 메서드를 사용하여 구조화된 데이터와 기능을 가질 수 있다. 즉 하나의 새로운 사용자 정의 데이터 타입을 만들어 주는 것이다.구조체의 인스턴스는 값 타입이며, 클래스의 인스턴스는 참조 타입이라는게 가장 큰 차이점이다.구조체구조체는 아래와 같이 정의할 수 있다.struct 구조체이름 { 프로퍼티와 메서드들 } 위의 구조처럼 구성을 하나 이해를 위해서는 실제 사용 사례를 보자struct Student { var name : String var age : Int } 이름과 나이라는 저장 프로퍼티를 가지고 있는 구조체를 만들어보았다. 이후 이를 기반으로 인스턴스를 생성하고 초기화할 수 있다.// Student(name:,age:)로 자동 생성된..

    [Swifft] GCD란 무엇인가?

    GCDGCD(Grand Central Dispatch)는 해야할 어떤 일들을 만들어서 넘기면(코드 블록) 시스템에서 스레드를 할당하고 안전하게 수행/처리해준다.queue를 이용해서 관리를 하게 되는데, queue란 하나의 자료 구조이다. First-in First-out만 알아두면 되는데, queue에 먼저 들어온 0번 테스크를 밖으로 내보내고 그 다음 번을 내보내는 자료구조를 말하는 것이다.GCD + DispatchQueue의 형태로 이용을 하는데, 이 DispatchQueue에는 세 가지 타입이 있다. 1. Main Queue 메인 스레드에서 작동하는 queue이다.DispatchQueue.main.async { // Tasks } 형태로 사용이 된다.// - Main QueueDispatchQueu..