Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Clean Swift Workshop
Search
Chiaote Ni
November 08, 2020
Programming
830
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Clean Swift Workshop
Chiaote Ni
November 08, 2020
More Decks by Chiaote Ni
See All by Chiaote Ni
MCP - iPlayground
chiaoteni
0
140
Swift Testing - iPlayground
chiaoteni
0
310
Swift Package Manager
chiaoteni
0
170
Swift Smart KeyPath
chiaoteni
0
1.4k
Other Decks in Programming
See All in Programming
AHC070解法紹介
eijirou
0
140
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
200
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
320
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
940
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
360
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
310
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
3.2k
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
120
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
350
アクセシビリティから考える情報設計
high_g_engineer
0
410
速習iPhone Duo対応
yuukiw00w
2
830
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
760
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
From π to Pie charts
rasagy
1
380
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Designing for Timeless Needs
cassininazir
1
510
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
470
The untapped power of vector embeddings
frankvandijk
2
1.9k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
How to build a perfect <img>
jonoalderson
1
6k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
540
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
520
Transcript
Clean Swift A better architecture to make project testable iOS@Taipei
艾倫 Ni & William Kuo
What is Clean Swift?
ViewController
Scene
Interactor Presenter ViewController
ViewController Interactor Presenter Display Logic Business Logic Presentation Logic ViewController
Interactor Presenter Display Logic Business Logic Presenta tion Logic
ViewControll Interact Presenter Display Logic Business Logic Presentation Logic Worker
Worker Worker
Worker ORM / DB Local API Network / API Network
API ViewControll Interact Presenter Display Logic Business Logic Presentation Logic
Worker ViewControll Interact Presenter Display Logic Business Logic Presentation Logic
I13N Calculate Thumbnail resize Parse video’s metadata
Interactor Presenter ViewController Request Response ViewModel
None
Boundary
viewContorller interactor presentor in out in out DisplayLogic in out
Boundary Boundary Boundary BusinessLogic Presentation Logic
protocol MeetupEventListDisplayLogic: AnyObject { func displayMeetupEvents(viewModel: MeetupEventList.FetchEvents.ViewModel) func displayUpdateHistoryEvent(viewModel: MeetupEventList.UpdateHistoryEvent.ViewModel)
} final class MeetupEventListViewController: UIViewController, MeetupEventListDisplayLogic { } protocol MeetupEventListBusinessLogic { func fetchMeetupEvents(request: MeetupEventList.FetchEvents.Request) func tapFavorite(request: MeetupEventList.TapFavorite.Request) func subscribeFavoriteUpdate(request: MeetupEventList.SubscribeFavoriteUpdate.Request) func unsubscribeFavoriteUpdate(request: MeetupEventList.UnsubscribeFavoriteUpdate.Request) } final class MeetupEventListInteractor: MeetupEventListBusinessLogic { } protocol MeetupEventListPresentationLogic { func presentMeetupEvents(response: MeetupEventList.FetchEvents.Response) func presentUpdateHistoryEvent(response: MeetupEventList.UpdateHistoryEvent.Response) } final class MeetupEventListPresenter: MeetupEventListPresentationLogic { }
BusinessLogic in out Boundary private func private func private func
private func Test
What’s more?
ViewController Interactor DataStore Router Data Passing Routing
Workshop Practice
None
基礎版 進階版
None
None
Interactor Presenter ViewController Request Response ViewModel struct Request { }
struct ViewModel { let historyEvents: [] let recentlyEvents: [] } struct Response { let recentlyEvents: [EventResponseItem] let historyEvents: [EventResponseItem] }
enum MeetupEventList { enum FetchEvents { struct Request { }
struct Response { let recentlyEvents: [EventResponseItem] let historyEvents: [EventResponseItem] } struct ViewModel { let historyEvents: [DisplayHistoryEvent] let recentlyEvents: [DisplayRecentlyEvent] } } }
Presentation Model
struct DisplayRecentlyEvent { let id: String let title: String let
dateText: String let hostName: String let coverImageURL: URL? }
struct DisplayHistoryEvent { let id: String let title: String let
dateText: String let hostName: String let coverImageURL: URL? let favoriteButtonColor: UIColor }
How?
class MeetupEventListViewController: UIViewController { } var recentlyEvents: [MeetupEvent] = []
var historyEvents: [MeetupEvent] = [] ViewController (MVC)
var recentlyEvents: [MeetupEventList.DisplayRecentlyEvent] = [] var historyEvents: [MeetupEventList.DisplayHistoryEvent] = []
protocol MeetupEventListDisplayLogic: AnyObject { func displayMeetupEvents( viewModel: MeetupEventList.FetchEvents.ViewModel ) } class MeetupEventListViewController: UIViewController, MeetupEventListDisplayLogic { } ViewController (Clean Swift)
meetupEventListAPI.fetchMeetupEvents { [weak self] result in guard let self =
self else { return } switch result { case let .success((recentlyEvents, historyEvents)): self.recentlyEvents = self.recentlyEvents self.historyEvents = self.historyEvents self.tableView.reloadData() case let .failure(error): print("#### error -> \(error)") } } loadData( ) (MVC)
let request: MeetupEventList.FetchEvents.Request = .init() interactor?.fetchMeetupEvents(request: request) loadData( ) (Clean
Swift)
func configureCell(with meetupEvent: MeetupEvent) { titleLabel.text = meetupEvent.title hostNameLabel.text =
meetupEvent.hostName if let eventDate = meetupEvent.date { dateLabel.text = getDateText(with: eventDate) } else { dateLabel.text = "" } coverImageView.image = nil if let coverImageUrl = meetupEvent.coverImageLink, let url = URL(string: coverImageUrl) { coverImageView.isHidden = false coverImageView.kf.setImage(with: url) } else { coverImageView.isHidden = true } } Configure Cell (MVC)
func configureCell( with meetupEvent: MeetupEventList.DisplayRecentlyEvent ) { titleLabel.text = meetupEvent.title
hostNameLabel.text = meetupEvent.hostName dateLabel.text = meetupEvent.dateText coverImageView.image = nil if let url = meetupEvent.coverImageURL { coverImageView.isHidden = false coverImageView.kf.setImage(with: url) } else { coverImageView.isHidden = true } } Configure Cell (Clean Swift)
protocol MeetupEventListBusinessLogic { func fetchMeetupEvents( request: MeetupEventList.FetchEvents.Request ) } class
MeetupEventListInteractor: MeetupEventListBusinessLogic{ var fetchMeetupEventWorker: MeetupEventListAPIWorker func fetchMeetupEvents( request:MeetupEventList.FetchEvents.Request ) { } } Interactor (Clean Swift)
protocol MeetupEventListPresentationLogic { func presentMeetupEvents( response: MeetupEventList.FetchEvents.Response ) } class
MeetupEventListPresenter:MeetupEventListPresentationLogic { func presentMeetupEvents( response: MeetupEventList.FetchEvents.Response ){ } } Presenter (Clean Swift)
活動時間: 每週⼆ pm: 8:30 ~ 10:00 (每⽉第⼀週休) 活動地點:線上聚會 || Meet.jobs
辦公室 (感謝Meet.jobs 提供場地)
聯絡資訊(email) 聯絡資訊(LinkedIn) 我們在招⼈~ beanfun!的iOS團隊需要你 ⽬前我們正在以Clean Swift為主架構 重構整個beanfun! App ⽬前預計明年1⽉會上線
如果你對這個機會有興趣,想了解更多資訊 歡迎email給我,或加我LinkedIn聊聊唷
練習專案 完成版 Clean Swift 討論群
Thanks for your attention.