Implementing factory design pattern in Swift

https://gist.github.com/kmdarshan/d425061bba80394fe1dc7405c3efb074

3 responses

  1. Antonio Montes Avatar
    Antonio Montes

    class Map {
    let type : Int = 0
    func showMap…
    should be:
    class Map {
    let type: Int = 0
    func makeMap…
    and then:
    let map = Map()
    map.makeMap(type: Maps.google).showMap()
    map.makeMap(type: Maps.apple).showMap()
    will show:
    showing google map
    showing apple map

    1. darshan Avatar
      darshan

      Why would you suggest that ?

Leave a Reply

Your email address will not be published. Required fields are marked *