HubFramework icon indicating copy to clipboard operation
HubFramework copied to clipboard

HubViewController as protocol

Open marmelroy opened this issue 7 years ago • 4 comments

@cerihughes and I discussed the fact that subclassing HubViewController in order to define a contract (i.e. act as a protocol) was a bit strange.

The argument against it was that Swift will look at UIViewController<HubViewController> as just a UIViewController and there will be lots of casting in the Swift code.

That's true (for now).

However, Swift looks at id<HubViewController> as a HubViewController protocol.

Going with this approach, there's only one line of casting in the Swift code and that's only to make UIKit happy. I think that's acceptable.

marmelroy avatar Apr 12 '17 12:04 marmelroy

... but if we do create a protocol for the VC (there are still other cases where it's easier if it's a concrete class), we'd want to expose this in the API as UIViewController<HUBViewController> *, not id<HUBViewController>.

I think we should get to a point where we're not experimenting so much with different VC implementations and then look at whether using a protocol in the API is feasible.

For now, let's keep it as it is.

cerihughes avatar Apr 12 '17 12:04 cerihughes

23 Errors
:no_entry_sign: fatal error: too many errors emitted, stopping now [-ferror-limit=]
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L259: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L564: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L270: no known instance method for selector ‘viewDidAppear:’
[weakViewController viewDidAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L542: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L276: no known instance method for selector ‘loadView’
[self.viewController loadView];
:no_entry_sign: Couldn’t find the (junit) unit test report file in ‘build/tests-dynamic’. Make sure the tests were actually run.
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L277: no known instance method for selector ‘viewDidLoad’
[self.viewController viewDidLoad];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L544: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L279: no known instance method for selector ‘viewDidLayoutSubviews’
[self.viewController viewDidLayoutSubviews];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L593: no known instance method for selector ‘viewDidLayoutSubviews’
[self.viewController viewDidLayoutSubviews];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L281: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L524: no known instance method for selector ‘viewDidLayoutSubviews’
[self.viewController viewDidLayoutSubviews];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L290: no known instance method for selector ‘viewDidAppear:’
[weakViewController viewDidAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L543: no known instance method for selector ‘viewDidLayoutSubviews’
[self.viewController viewDidLayoutSubviews];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L330: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L545: no known instance method for selector ‘viewDidLayoutSubviews’
[self.viewController viewDidLayoutSubviews];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L521: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L565: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L522: no known instance method for selector ‘viewDidLayoutSubviews’
[self.viewController viewDidLayoutSubviews];
:no_entry_sign: Couldn’t find the (junit) unit test report file in ‘build/tests-static’. Make sure the tests were actually run.
:no_entry_sign: tests/HUBViewControllerImplementationTests.m#L523: no known instance method for selector ‘viewWillAppear:’
[self.viewController viewWillAppear:YES];
:no_entry_sign: Couldn’t find the (junit) unit test report file in ‘build/ui-tests’. Make sure the tests were actually run.

Generated by :no_entry_sign: Danger

spotify-ci-bot avatar Apr 12 '17 12:04 spotify-ci-bot

@marmelroy @cerihughes With Swift 4 it’ll be possible to expose and use types as UIViewController<HUBViewController>. So “all” will be good in about 6 months time.

rastersize avatar Apr 21 '17 20:04 rastersize

@rastersize, can't wait :)

marmelroy avatar Apr 21 '17 20:04 marmelroy