Swift 100 Days: Project 18 - Collectionview in Tableview & Youtube Helper & MORE!!!

Sunny, Lee
4 min readDec 2, 2017

Environment: Swift 4 / Day: 37~47 / Date: Dec. 02, 2017 / Time: 50 hours

我學到什麼:(P.S. 此為正職工作內容)

・Alamofire, ObjectMapper 實作,Data 處理
・CollectionView in TableView,資料串接與傳遞(非常複雜Q)
・AVPlayer 搭配
Youtube Helper 應用
・Tableview Cell 延展 collapsable

小知識:

垂直滑動+水平滑動:Collectionview in Tableview Cell

資料搜尋中,我主要找到以下三個有用的資訊。

BUT,最麻煩的是 Datasource 的處理!!!

倘若專案中,在同一個 viewcontroller 使用 Alamofire 抓取資料,是不適用以上第一種方式,也就是 data 已經處理好並存放在一個 [[data]] 中,並在tableview willDisplay 或 cellForRowAt 中更新 collectionview。

Why? 很明顯地,從 Alamofire 獲取資料,並不會好端端的存放在一個 [[data]],也就是 data 根本還沒到位,在 tableView 中 willDisplay 或 cellForRowAt 中更新 collectionView 時,collectionView 的 datasource 還沒準備好,就報錯了。

短期非常糟糕的解法:強迫 data 全部 load 完,再 run 頁面。

正確解法,我腦海中有幾個idea,待我思索清楚,測試成功後,再 update~ 值得寫成一篇大文了我的天,真是個複雜的介面呀!

心得:

下週,是兩個 App 的預計截止日,也就是在一個月內,一個人、一台只有 4GB 的 Air ,如火如荼的 從 0 到 1 ,刻出兩個中型專案,其中一個要自包 Firebase 當後端,另一個則第一次從頭到尾串了各式各樣的 API。

希望下週可以完成這兩項艱難的任務,並有時間打一篇,這個月來每天12h+工時,兩份工作的心得文。

有如強風暴雨中,逆風而行的掙扎,因為強烈的信仰,我每一步都走得堅毅。

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Sunny, Lee
Sunny, Lee

Written by Sunny, Lee

CMU Master of Software Engineering student who loves outdoor activities

Responses (1)

Write a response

你真的好厲害好崇拜呀
光看你的文就感覺到你的努力!

--