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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
160
Swift Smart KeyPath
chiaoteni
0
1.4k
Other Decks in Programming
See All in Programming
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
2
270
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
180
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
260
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
320
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
130
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
130
巨大モノリシックアプリ モダン化大作戦
ktcryomm
0
440
Webの地図
yosuke_furukawa
PRO
5
3.9k
自分的「カンファレンスの楽しみ方」
syumai
0
200
フロントエンドUIフレームワークのこれまでとこれから
ssssota
4
2.1k
typoなんかねぇよ
raspython3
0
680
Featured
See All Featured
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
930
Chasing Engaging Ingredients in Design
codingconduct
0
300
Documentation Writing (for coders)
carmenintech
77
5.5k
BBQ
matthewcrist
89
10k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
840
YesSQL, Process and Tooling at Scale
rocio
174
15k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
980
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
A Tale of Four Properties
chriscoyier
163
24k
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.