분류 전체보기 18

[Swift] Server is not correctly configured.

오류코드 iOS에서 AVPlayer, AVURLAssets 을 이용하여 mp4 동영상을 재생하려다가 발생한 오류이다. - byte range length mismatch - NSOSStatusErrorDomain Code=-12939 Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped" UserInfo={NSUnderlyingError=0x7f927ede4210 {Error Domain=NSOSStatusErrorDomain Code=-12939 "(null)"} , NSLocalizedFailureReason=The server is not correctly configured., NSLocalizedDescription=Operation St..

카테고리 없음 2022.07.21

[Swift]프로그래머스 징검다리

다른 블로그에서는 주로 이분탐색을 중점적으로 설명하였는데, '최솟값 x가 되려면 몇 개의 바위를 제거해야하는 가' 부분의 이해가 어려웠다. 이 부분을 중점적으로 포스팅해 보려한다. 문제 출발지점부터 distance만큼 떨어진 곳에 도착지점이 있습니다. 그리고 그사이에는 바위들이 놓여있습니다. 바위 중 몇 개를 제거하려고 합니다. 출발지점부터 도착지점까지의 거리 distance, 바위들이 있는 위치를 담은 배열 rocks, 제거할 바위의 수 n이 매개변수로 주어질 때, 바위를 n개 제거한 뒤 각 지점 사이의 거리의 최솟값 중에 가장 큰 값을 return 하도록 solution 함수를 작성해주세요. 해결법 문제에서는 바위를 n개 없앴을 때, 각 지점 사이의 거리의 최솟값 중 가장 큰 값을 구하라는 문제이다...

카테고리 없음 2022.05.06

[Swift][iOS] 이미지뷰 버튼처럼 사용하기 UIImageView -> UIButton

import UIKit class ViewController: UIViewController { //MARK: 스토리보드와 코드 연결 @IBOutlet var imageView: UIImageView! //MARK: 이미지뷰 클릭시 호출될 함수 @objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer) { print("do something.") } override func viewDidLoad() { super.viewDidLoad() // ... //MARK: 제스처인식기 생성 및 연결 //제스처인식기 생성 let tapImageViewRecognizer = UITapGestureRecognizer(target: self, action:..

카테고리 없음 2022.03.17

[Swift]프로그래머스-여행 경로(DFS) 문제 풀이 정답 답안

출처: https://icksw.tistory.com/228 [프로그래머스] 여행경로 [Swift] 문제 링크 코딩테스트 연습 - 여행경로 [["ICN", "SFO"], ["ICN", "ATL"], ["SFO", "ATL"], ["ATL", "ICN"], ["ATL","SFO"]] ["ICN", "ATL", "ICN", "SFO", "ATL", "SFO"] programmers.co.kr 문제 설명 주어진 항.. icksw.tistory.com import Foundation func solution(_ tickets:[[String]]) -> [String] { //도착지를 기준으로 티켓을 알파벳순으로 정렬. let tickets = tickets.sorted { $0[1] < $1[1]} //티켓 사..

카테고리 없음 2022.03.07

[Swift][iOS]테이블뷰(UITableView) 최상단 잘림 해결

예제를 실습하면서 테이블뷰 최상단이 잘리는 현상이 발생했다. 위와 같은 문제는 아래처럼 테이블뷰 contentInset에 여백을 추가해줘서 해결할 수 있다. override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. //... //테이블뷰 최상단에 여백 추가 self.tableView.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0) }

카테고리 없음 2022.03.07

[Java]프로그래머스-단어변환(DFS/BFS) 문제 풀이 정답 답안

class Solution { int answer; boolean[] chk; public int solution(String begin, String target, String[] words) { answer = 51; chk = new boolean[words.length]; dfs(begin, target, 0, chk, words); return (answer == 51) ? 0: answer; } void dfs(String presentWord, String target, int n, boolean[] chk, String[] words) { //탐색이 끝났으면 if(presentWord.equals(target)) { //기존에 찾은 변환과정보다 짧은지 확인 후 업데이트 answer = (n..

카테고리 없음 2022.03.04

[Java]프로그래머스-네트워크(DFS/BFS) 문제 풀이 정답 답안

class Solution { public int solution(int n, int[][] computers) { int answer = 0; boolean[] chk = new boolean[n]; //방문여부저장 for(int i = 0 ; i < computers.length ; i++) { //해당 컴퓨터가 방문된 적이 없으면 if(!chk[i]) { //해당 컴퓨터를 시작으로 방문 실행. dfs(computers, chk, i); //네트워크 하나가 탐색되었음으로 카운트+1 answer++; } } return answer; } //컴퓨터 연결정보 행렬, 컴퓨터 방문여부, 시작 컴퓨터 void dfs(int[][] computers, boolean[] chk ,int start) { //시작 ..

카테고리 없음 2022.03.01