Giter VIP home page Giter VIP logo

Comments (6)

radianttap avatar radianttap commented on June 16, 2024 2

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.

radianttap avatar radianttap commented on June 16, 2024 1

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.

IsmailHassanein avatar IsmailHassanein commented on June 16, 2024

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.

xieweizhi avatar xieweizhi commented on June 16, 2024

@radianttap , I think it's a Swift 4 issue. Will you consider update the project to support Swift 4?

from coordinator.

falsecrypt avatar falsecrypt commented on June 16, 2024

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 UIViewControllers 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 Enums 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 UILabels : 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.

radianttap avatar radianttap commented on June 16, 2024

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. Swift Enums because of errors like Method 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 like fetchPromotedProducts and making them accessible from e.g. all UILabels : 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.

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.