iOS
-
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: ..
-
iOS) Dynamic TextView의 Underline - TextView에 밑줄 추가하기iOS 2021. 3. 5. 10:56
textField에 under line을 생성하는 예제는 많다. dynamic textView를 생성하는 예제도 많다. 둘을 합쳐보자. 우선 textView에 under line을 추가하는 코드이다. func underLine() { let border = CALayer() border.frame = CGRect(x: 0, y: self.frame.size.height-1, width: self.frame.width, height: 1) border.borderWidth = 1 border.backgroundColor = UIColor.black.cgColor self.layer.addSublayer(border) } 간단하게 layer를 textView의 frame에 맞추어 만들어 sublayer로 추..
-
iOS) CoreData - perform 메소드iOS 2021. 1. 31. 13:32
출처: www.kairadiagne.com/2019/01/06/understanding-the-core-data-perform-methods.html Understanding the Core Data perform methods Core Data is controversial to many developers. Some love it while others think it is too difficult or that it contains too many bugs. Personally I enjoy using Core Data. Out of the box it provides a lot of functionality needed for managing the model layer www.kairadiagn..
-
iOS) Core Data (4) - Entity Hierarchy and RelationshipiOS 2021. 1. 31. 05:38
summary - Entity 계층 구현 - Batch Insert - Relationship - Data Import Core Data는 두가지 관계를 지원한다. To - One Relationship: 두 개의 entity가 1대1로 연결된 관계 To - Many Relationship: 1대 다로 연결되는 관계 부서와 직원을 생각해보면 하나의 부서와 여러 직원이 연결되므로 Department가 source라면 Employee를 destination으로 to-many 관계다. Core Data model에서 Person, Employee, Department 엔티티를 만들고 이들의 관계를 형성하자. 우선 Employee는 Person을 상속하고 Department는 Employee와 To - Many..