SlideShare a Scribd company logo
1 of 49
Download to read offline


📦


📦


















👊😤💢










class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var tweets: [Tweet] = []
override func viewDidLoad() {
super.viewDidLoad()
TwitterManager.shared.getTweets() { [unowned self] result in
switch result {
case .success(let tweets):
self.tweets = tweets
self.tableView.reloadData()
case .failure:
() //
}
}
}
}
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var tweets: [Tweet] = []
override func viewDidLoad() {
super.viewDidLoad()
TwitterManager.shared.getTweet() { [unowned self] result in
switch result {
case .success(let tweets):
self.tweets = tweets
self.tableView.reloadData()
case .failure:
() //
}
}
}
}
👊😤💢








protocol ViewControllerOutput: class {
func reloadTableView()
}
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var presenter: SomePresenter!
override func viewDidLoad() {
super.viewDidLoad()
presenter = SomePresenter(output: self)
presenter.getTweets()
}
}
extension ViewController: ViewControllerOutput {
func reloadTableView() {
tableView.reloadData()
}
}
protocol ViewControllerOutput: class {
func reloadTableView()
}
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var presenter: SomePresenter!
override func viewDidLoad() {
super.viewDidLoad()
presenter = SomePresenter(output: self)
presenter.getTweets()
}
}
extension ViewController: ViewControllerOutput {
func reloadTableView() {
tableView.reloadData()
}
}
protocol ViewControllerOutput: class {
func reloadTableView()
}
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var presenter: SomePresenter!
override func viewDidLoad() {
super.viewDidLoad()
presenter = SomePresenter(output: self)
presenter.getTweets()
}
}
extension ViewController: ViewControllerOutput {
func reloadTableView() {
tableView.reloadData()
}
}
class SomePresenter {
let output: ViewControllerOutput!
var tweets: [Tweet] = []
init(output: ViewControllerOutput) {
self.output = output
}
func getTweets() {
TwitterManager.shared.getTweets() { [unowned self] result in
switch result {
case .success(let tweets):
self.tweets = tweets
self.output.reloadTableView()
case .failure:
() //
}
}
}
}
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var presenter: SomePresenter!
override func viewDidLoad() {
super.viewDidLoad()
presenter = SomePresenter(output: self)
presenter.getTweets()
}
}
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var tweets: [Tweet] = []
override func viewDidLoad() {
super.viewDidLoad()
getTweets() { [unowned self] result in
switch result {
case .success(let tweets):
self.tweets = tweets
self.tableView.reloadData()
case .failure:
() //
}
}
}
}






👋










💰


👭
MVP 💪


















🍻
描画とビジネスをクリーンに分ける Osaka 公開用

More Related Content

Similar to 描画とビジネスをクリーンに分ける Osaka 公開用

Apple Templates Considered Harmful
Apple Templates Considered HarmfulApple Templates Considered Harmful
Apple Templates Considered Harmful
Brian Gesiak
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actions
Eyal Vardi
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
Tse-Ching Ho
 

Similar to 描画とビジネスをクリーンに分ける Osaka 公開用 (20)

Practical Protocol-Oriented-Programming
Practical Protocol-Oriented-ProgrammingPractical Protocol-Oriented-Programming
Practical Protocol-Oriented-Programming
 
Practialpop 160510130818
Practialpop 160510130818Practialpop 160510130818
Practialpop 160510130818
 
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in SwiftMCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
MCE^3 - Natasha Murashev - Practical Protocol-Oriented Programming in Swift
 
Everything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View ControllersEverything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View Controllers
 
RxBinding-kotlin
RxBinding-kotlinRxBinding-kotlin
RxBinding-kotlin
 
Say bye to Fragments with Conductor & Kotlin
Say bye to Fragments with Conductor & KotlinSay bye to Fragments with Conductor & Kotlin
Say bye to Fragments with Conductor & Kotlin
 
Smooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionViewSmooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionView
 
Apple Templates Considered Harmful
Apple Templates Considered HarmfulApple Templates Considered Harmful
Apple Templates Considered Harmful
 
ASP.NET MVC Internals
ASP.NET MVC InternalsASP.NET MVC Internals
ASP.NET MVC Internals
 
Working effectively with ViewModels and TDD - UA Mobile 2019
Working effectively with ViewModels and TDD - UA Mobile 2019Working effectively with ViewModels and TDD - UA Mobile 2019
Working effectively with ViewModels and TDD - UA Mobile 2019
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actions
 
Secret unit testing tools
Secret unit testing toolsSecret unit testing tools
Secret unit testing tools
 
Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View Controllers
 
Testing C# and ASP.net using Ruby
Testing C# and ASP.net using RubyTesting C# and ASP.net using Ruby
Testing C# and ASP.net using Ruby
 
French kit2019
French kit2019French kit2019
French kit2019
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
Swf2 ui
Swf2 uiSwf2 ui
Swf2 ui
 
I os 11
I os 11I os 11
I os 11
 
Optimize CollectionView Scrolling
Optimize CollectionView ScrollingOptimize CollectionView Scrolling
Optimize CollectionView Scrolling
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
 

More from Kenji Tanaka

リリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_night
リリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_nightリリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_night
リリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_night
Kenji Tanaka
 

More from Kenji Tanaka (20)

FatViewControllerを安全に書き換える方法が見つからなかったので、どういう痛みを許容するか考えた #iosdc
FatViewControllerを安全に書き換える方法が見つからなかったので、どういう痛みを許容するか考えた #iosdcFatViewControllerを安全に書き換える方法が見つからなかったので、どういう痛みを許容するか考えた #iosdc
FatViewControllerを安全に書き換える方法が見つからなかったので、どういう痛みを許容するか考えた #iosdc
 
リリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_night
リリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_nightリリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_night
リリース前のリグレッションテストがめんどい!のでMagic PodでUIテストを試してみる #pixiv_app_night
 
ポストモーテムやってみた #yjbonfire
ポストモーテムやってみた #yjbonfireポストモーテムやってみた #yjbonfire
ポストモーテムやってみた #yjbonfire
 
2つの同期 4つの状態 #pixiv_ios_arch
2つの同期 4つの状態 #pixiv_ios_arch2つの同期 4つの状態 #pixiv_ios_arch
2つの同期 4つの状態 #pixiv_ios_arch
 
2つの同期 4つの状態 #app_mp
2つの同期 4つの状態 #app_mp2つの同期 4つの状態 #app_mp
2つの同期 4つの状態 #app_mp
 
2つの同期 4つの状態 #roppongiswift
2つの同期 4つの状態 #roppongiswift2つの同期 4つの状態 #roppongiswift
2つの同期 4つの状態 #roppongiswift
 
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_nightトークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
 
よく使うテストヘルパーの紹介 #ios_test_night
よく使うテストヘルパーの紹介 #ios_test_nightよく使うテストヘルパーの紹介 #ios_test_night
よく使うテストヘルパーの紹介 #ios_test_night
 
Swiftで聞いておぼえるテスト書き
Swiftで聞いておぼえるテスト書きSwiftで聞いておぼえるテスト書き
Swiftで聞いておぼえるテスト書き
 
設計時空のリファクタリング
設計時空のリファクタリング設計時空のリファクタリング
設計時空のリファクタリング
 
WACATE 2018 Summer
WACATE 2018 SummerWACATE 2018 Summer
WACATE 2018 Summer
 
テスト駆動開発入門 by Swift
テスト駆動開発入門 by Swiftテスト駆動開発入門 by Swift
テスト駆動開発入門 by Swift
 
An iOS Engineer challenges Web.
An iOS Engineer challenges Web.An iOS Engineer challenges Web.
An iOS Engineer challenges Web.
 
エンジニアのためのブログ講座Ver4
エンジニアのためのブログ講座Ver4エンジニアのためのブログ講座Ver4
エンジニアのためのブログ講座Ver4
 
TDDやってみよ
TDDやってみよTDDやってみよ
TDDやってみよ
 
ストレス社会に生きる、iOSエンジニアにオススメする百合の世界と作品
ストレス社会に生きる、iOSエンジニアにオススメする百合の世界と作品ストレス社会に生きる、iOSエンジニアにオススメする百合の世界と作品
ストレス社会に生きる、iOSエンジニアにオススメする百合の世界と作品
 
節子、それViewControllerやない...、FatViewControllerや...。
節子、それViewControllerやない...、FatViewControllerや...。節子、それViewControllerやない...、FatViewControllerや...。
節子、それViewControllerやない...、FatViewControllerや...。
 
iOS 11からのDeviceCheck #とは
iOS 11からのDeviceCheck #とはiOS 11からのDeviceCheck #とは
iOS 11からのDeviceCheck #とは
 
設計に答えはないから探してみよう
設計に答えはないから探してみよう設計に答えはないから探してみよう
設計に答えはないから探してみよう
 
iOS 11からのアプリ間ファイル共有
iOS 11からのアプリ間ファイル共有iOS 11からのアプリ間ファイル共有
iOS 11からのアプリ間ファイル共有
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

描画とビジネスをクリーンに分ける Osaka 公開用

  • 1.
  • 3.
  • 4.
  • 5.
  • 6.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 18.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 26.
  • 27.
  • 28. class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var tweets: [Tweet] = [] override func viewDidLoad() { super.viewDidLoad() TwitterManager.shared.getTweets() { [unowned self] result in switch result { case .success(let tweets): self.tweets = tweets self.tableView.reloadData() case .failure: () // } } } }
  • 29. class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var tweets: [Tweet] = [] override func viewDidLoad() { super.viewDidLoad() TwitterManager.shared.getTweet() { [unowned self] result in switch result { case .success(let tweets): self.tweets = tweets self.tableView.reloadData() case .failure: () // } } } } 👊😤💢
  • 30.
  • 31.
  • 33. protocol ViewControllerOutput: class { func reloadTableView() } class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var presenter: SomePresenter! override func viewDidLoad() { super.viewDidLoad() presenter = SomePresenter(output: self) presenter.getTweets() } } extension ViewController: ViewControllerOutput { func reloadTableView() { tableView.reloadData() } }
  • 34. protocol ViewControllerOutput: class { func reloadTableView() } class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var presenter: SomePresenter! override func viewDidLoad() { super.viewDidLoad() presenter = SomePresenter(output: self) presenter.getTweets() } } extension ViewController: ViewControllerOutput { func reloadTableView() { tableView.reloadData() } }
  • 35. protocol ViewControllerOutput: class { func reloadTableView() } class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var presenter: SomePresenter! override func viewDidLoad() { super.viewDidLoad() presenter = SomePresenter(output: self) presenter.getTweets() } } extension ViewController: ViewControllerOutput { func reloadTableView() { tableView.reloadData() } }
  • 36. class SomePresenter { let output: ViewControllerOutput! var tweets: [Tweet] = [] init(output: ViewControllerOutput) { self.output = output } func getTweets() { TwitterManager.shared.getTweets() { [unowned self] result in switch result { case .success(let tweets): self.tweets = tweets self.output.reloadTableView() case .failure: () // } } } }
  • 37. class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var presenter: SomePresenter! override func viewDidLoad() { super.viewDidLoad() presenter = SomePresenter(output: self) presenter.getTweets() } } class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var tweets: [Tweet] = [] override func viewDidLoad() { super.viewDidLoad() getTweets() { [unowned self] result in switch result { case .success(let tweets): self.tweets = tweets self.tableView.reloadData() case .failure: () // } } } }
  • 38.
  • 40.
  • 41.
  • 43.
  • 44.
  • 46.
  • 48. 🍻