Comments (6)
Yes, because it's all based on UIResponder. Add dynamic
before coordinatingResponder methods and compiler will inform you about issues with non-ObjC types as soon as you write them.
dynamic func cartBuyNow(_ product: Product, sender: Any?) {
coordinatingResponder?.cartBuyNow(product, sender: sender)
}
from coordinator.
Library itself is working in both Swift 3 / 4. I have updated the demo project and used pods to Swift 4.
There's a separate swift3
branch in case you need to try it out.
from coordinator.
I found the problem. I was passing a variable of type isn't NSObject subclass. I got it when I tried to put the keyword @objc
before the function, then I got an error that param 1 is not objective c representable.
Thank you.
from coordinator.
@radianttap , I think it's a Swift 4 issue. Will you consider update the project to support Swift 4?
from coordinator.
I see some problems however in your (@radianttap) implementation of the "Coordinator" pattern. For example you are using UIResponder
extensions and not Delegates to connect UIViewController
s and Coordinators. Here you must use @objc dynamic func
to make it work but it means we also must use objc parameters only and not e.g. Swift Enum
s because of errors like Method cannot be marked @objc because the type of the parameter 2 cannot be represented in Objective-C
.
Secondly you are polluting the interfaces of all objects that inherit from UIResponder
with domain-specific methods like fetchPromotedProducts
and making them accessible from e.g. all UILabel
s : nameLabel.fetchPromotedProducts
[...] which compiles fine but makes no sense at all and of course UILabels
should not be aware of any kind of domain/business logic.
This is not a complete list with problems only what i've seen so far.
from coordinator.
I have discussed this in the very first post I wrote about the pattern implementation, see Downsides at the end of this post.
Here you must use
@objc dynamic func
to make it work but it means we also must use objc parameters only and not e.g. SwiftEnum
s because of errors likeMethod cannot be marked @objc because the type of the parameter 2 cannot be represented in Objective-C
.
This is solved through boxing. See for example ColorBox in Color.swift in the example app.
Secondly you are polluting the interfaces of all objects that inherit from
UIResponder
with domain-specific methods likefetchPromotedProducts
and making them accessible from e.g. allUILabel
s :nameLabel.fetchPromotedProducts
[...] which compiles fine but makes no sense at all and of courseUILabels
should not be aware of any kind of domain/business logic.
Yep. Hence my continued emphasys on common sense. I don't attempt to save the developer from themself. Nor I think it's actually technically feasible to limit visibility of these methods while keeping the good parts.
This is not a complete list with problems only what i've seen so far.
I personally don't see these as problems – it's a deliberate choice on my part, a trade off between usability and what I can do in UIKit while working from outside of UIKit team.
(You may feel differently of course.)
from coordinator.
Related Issues (20)
- Rewinding state after stop/stopChild HOT 4
- Track `popViewController` when user taps Back bar button on iOS >= 10 HOT 6
- Return back the UINavigationController delegate to parent coordinator when share the UINavigationController HOT 2
- Support Carthage HOT 8
- Support Swift Package manager HOT 2
- Add shields.io badges
- Non-animated pop is not detected in NavigationCoordinator HOT 5
- Bloated Namespace HOT 1
- Unable to compile CoordinatorExample.xcodeproj HOT 2
- [Refactor] :Make code clean HOT 6
- How to compile and run the example app? HOT 1
- Cocoapods error HOT 2
- handlePopBack is not called when 2 coordinators share the same rootViewController HOT 3
- Tutorial request - A sample xcproject? HOT 1
- Crash on Accessing Parent Coordinator HOT 3
- Can't use Struct as params in UIResponder's method HOT 1
- Bubbling events in the responder chain HOT 4
- Track Dismissal of RootViewController HOT 3
- UITabBarController as Root or Child Coordinator HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coordinator.