분류 전체보기
-
Data(contentsOf:)? URLSession?Swift 2022. 8. 1. 16:26
Data(contentsOf:) 이미지를 받아와서 보여주는 가장 기본적인 예제 중 이런것이 있다. DispatchQueue.global().async { do { let image = try Data(contentsOf: self.imageUrl) DispatchQueue.main.async { self.imageView.image = UIImage(data: image) } } catch { print(error) } } 개인적으로 이런 식의 데이터 통신을 접한 첫 것은 그 유명한 Standford iOS강의 일것이다. 물론 지금 와선 그 의도를 파악 할 수 있지만(빨리 보여줘야 하니까…ㅎㅎ) 처음 접한 방식이 이렇다 보니 당연히 네트워크 통신은 이런식으로 하는줄 알았다. 통신은 무조건 Dispatch..
-
AVAudioFile과 AVAudioBufferiOS 2022. 6. 30. 18:31
AVAudioFile An object that represents an audio file that the system can open for reading or writing. 시스템이 읽고 쓰기위해 열수 있는 오디오 파일을 나타내는 객체 우린 파일의 format에 상관없이 AVAudioPCMBuffer 객체를 통해 읽거나 쓸 수 있다. 이러한 객체들에는 프레임워크에서 file processing format 으로 'AVAudioCommonFormat'이라는 샘플이 포함되어 있다. AVAudioFile을 통해 실제 파일 format으로 변환 하거나 변환 시킨다. 즉, AVAudioFile을 통해 실제 오디오 파일을 읽거나 쓸수 있게 만드는 것이다. AVAudioFile의 초기화 let file_Int..
-
CollectionView Cell 이동 시키기 (2) - UICollectionView Drag and Drop DelegateiOS 2022. 6. 10. 22:05
UICollectionView Drag And Drop Delegate iOS 11.0+ 에서 적용할 수 있는 drag and drop Delegate은 collectionView 뿐만 아니라 app과 app 사이의 copy/paste를 지원하고 content의 이동도 담당해준다. UICollectionView에서 제공 되는 Drag와 Drop delegate 사용하여 셀의 이동을 구현 해보자. collectionView.dragDelegate = self collectionView.dropDelegate = self 기존의 cell dragging의 트리거가 되는 매개체는 gestureRecognizer였지만, DragDelegate는 단순히 dragDelegate를 채택 해주므로써 작동된다. // D..
-
CollectionView Cell 이동 시키기 (1) - 기존 방식과 custom InteractiveMovementiOS 2022. 6. 9. 20:13
보통 CollectoinView의 cell을 이동하기 위해선 gesture을 붙이고 cell의 location을 이용하여 위치를 바꾼 후 해당 model의 데이터를 스왑해준다. @objc func handleLongPressGesture() { let location = longPress.location(in: collectionView) switch longPress.state { case .began: if let indexPath = collectionView.indexPathForItem(at: location) { collectionView.beginInteractiveMovementForItem(at: indexPath) } case .changed: collectionView.updateIn..
-
WWDC) Animation hitch와 render loopiOS 2022. 4. 5. 00:04
https://developer.apple.com/videos/play/tech-talks/10855/ Explore UI animation hitches and the render loop - Tech Talks - Videos - Apple Developer Explore how you can improve the performance of your app's user interface by identifying scrolling and animation hitches in your app... developer.apple.com 본 포스트 내용의 출처는 WWDC입니다. 의/오역이 있을 수 있습니다. 이 글에선 스크롤링과 애니메이션 hitches에 대해 알아보고 render loop에 대해 자세히 살..
-
Cocoapods) custom 라이브러리에 이미지 파일 embedded 하기iOS 2021. 8. 4. 16:00
라이브러리를 직접 만들면 이미지를 넣어야 할 때가 있다. 보통의 프로젝트에서 이미지를 넣어주는 assets폴더는 보이지 않고, 디렉토리를 통해 들어가면 나오는 Assets과 Classes 폴더에 이미지를 넣어도 도통 불러올 수 없다. 번들을 통해 디렉토리 안에 있는 이미지 파일 불러오기 file navigator에 원하는 이미지를 넣고 번들을 통해 불러온다. 그룹을 만들어도 된다. let bundle = Bundle(for: 클래스_이름.self) // 예제의 경우 UYRadioButton print(bundle) 번들을 주소를 찍어서 나오는 경로를 따라 가다보면 이렇게 막히게 된다. 터미널을 통해 경로로 이동 해보자. 위치에 정확히 이미지 파일이 존재한다. let bundle = Bundle(for: ..