Post

Replies

Boosts

Views

Activity

Comment on Swift Protocol Constraint Required - Advanced
Hi, thanks, sorry for delay, I really appreciated the help, but the goal is to have a generic FilterManager class, I don't want to use casting inside the init ... I found a way to do it (without using ANY, but I am sure with Swift 5.7 there is a better way to do it) ... I will share it you, give me 1-2 days and I will drop the code here.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Comment on Swift Protocol Constraint Required - Advanced
thanks but it does not work, the code compiles ok but if you try to instantiate the FiltersManager class you will have an error you can't pass an array of type Any SimpleFilter to filters typed as [U] in the class initializer Compiler error: Type 'any SimpleFilter' cannot conform to 'SimpleFilter' try this you will see let filters: [any SimpleFilter] = [CountryFilter(), RegionFilter()] var cities = [City]() let manager = TestFiltersManager(array: cities, filters: filters)
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22