본문 바로가기

iOS

(87)
[iOS] Diffable Data Source (CollectionView, TableView) UICollectionViewDiffableDataSource에 대한 이해를 자세하게 하기 위해 작성하였습니다. TableView, CollectionView 에서 사용하는 DataSource를 구성하는 방법에는 두가지가 있습니다. UICollectionViewDataSource protocol The methods adopted by the object you use to manage data and provide cells for a collection view. 데이터를 관리하고 collection view에 대한 cell을 제공합니다. UICollectionViewDiffableDataSource The object you use to manage data and provide cells for ..
[iOS] Identifiable 프로토콜 https://developer.apple.com/tutorials/app-dev-training/making-reminders-identifiable#Make-the-Model-Identifiable Apple Developer Documentation developer.apple.com Apple의 UIKit Tutorial (미리알림 앱)을 보고 공부한 내용을 정리한 글입니다. diffable data source는 collection view의 각 항목 ID를 나타내는 identifier list를 저장합니다. 이전 강의에서는 미리알림의 title 제목을 identifier로 지정하여 저장했는데 미리알림의 제목을 변경하거나 동일한 제목의 미리 알림(Reminder)이 있다면 그 cell을 나타내는..
[iOS] extension + Generic where https://developer.apple.com/tutorials/app-dev-training/making-reminders-identifiable Apple Developer Documentation developer.apple.com 오늘도 Apple 의 튜토리얼을 따라하다가 extension 에서 where 을 추가해서 사용하는 것을 보고 궁금해서 글을 적어봅니다. extension Array where Element == Reminder { func indexOfReminder(with id: Reminder.ID) -> Self.Index { guard let index = firstIndex(where: { $0.id == id }) else { fatalError() } return in..
[iOS] Format the Date and Time https://developer.apple.com/tutorials/app-dev-training/displaying-cell-info Apple Developer Documentation developer.apple.com Apple UIKit 튜토리얼 배운 것을 공부하여 정리하였습니다. 우선 배운 것을 정리하면 Foundation 프레임워크를 사용하고 해당하는 장소에 따라 시간을 비교하여 오늘인지 아닌지, 오늘이라면 'Today', 오늘이 아니라면 'Mar 8' 이렇게 나타내는 방법을 배웠습니다. Foundation 프레임워크의 Date 구조체를 extension해서 dayAndTimeText String 변수를 만들었습니다. dayAndTimeText extension Date { var dayAn..
[iOS] UICollectionViewDiffableDataSource https://developer.apple.com/tutorials/app-dev-training/creating-a-list-view Apple Developer Documentation developer.apple.com Apple UIkit tutorial을 보고 배운 내용을 정리한 글입니다. Configure the Data Source - diffable data source 이전글에서 만들었던 collection view 의 data source 로 difable data source 를 사용했습니다. diffable data source 라는 것을 처음 봤는데 데이터가 변경될 때 사용자 인터페이스를 업데이트하고 애니메이션 효과를 준다고 합니다. 사실 여기가 굉장히 복잡해서 (저에게는ㅎㅎ) 정..
[iOS] UICollectionViewLayout https://developer.apple.com/tutorials/app-dev-training/creating-a-list-view Apple Developer Documentation developer.apple.com iOS App Dev Tutorials 를 보면서 배운 내용을 정리하였습니다. Creating a List View 이전 튜토리얼에서는 리스트 뷰를 테이블뷰로 생성했었는데 이번 강의에서는 콜렉션뷰를 사용했습니다. 똑같이 Reminder 이라는 Model 을 생성하는데 달라진 점은 #if DEBUG, #endif 이 플래그는 realse 용 앱을 빌드할 때 코드가 컴파일되지 않도록 하는 컴파일 지시문입니다. 디버그 빌드에서 코드를 테스트하거나 샘플 테스트 데이터 제공을 위해 이 플래그..
[Swift] @escaping iOS App Dev tutorial 을 따라하던 도중에 @escaping 이 나와서 개념을 정리해보려고 합니다. @escaping을 사용한 전체 코드를 보면 ReminderListCell.swift 의 configure 함수의 파라미터에서 @escaping annotation을 사용했고, 이 configure 함수를 ReminderListViewController.swift에서 호출하고 있습니다. ReminderListCell.swift import UIKit class ReminderListCell: UITableViewCell { // like reference typealias DoneButtonAction = () -> Void @IBOutlet var titleLabel: UILabel! @I..
[소리마당 Proj] OX Quiz 구현 Quiz List JSON 형식으로 받아오기 Alamofire, SwiftyJSON 사용 사용한이유: 다른 데이터를 가져오는 코드보다 정말.. 간단 ㅎㅎ 했습니다.. [JSON] 형식으로 가져왔습니다. viewWillAppear 함수에서 퀴즈리스트를 게임 시작 시에 가져왔습니다. func requestQuizList() { AF.request(quizURL).responseJSON { response in if let value = response.value { let quizList = JSON(value).arrayValue self.quizList = quizList self.setQuiz(1) } } } issue quizURL 설정 중에 http:// 를 붙이지 않아 데이터를 불러오지 못한 상황..