0

I have created DTOUser, DTOLocation struct model and defined User, Location protocol like below

struct DTOUser {
    var name: String
    var age: Int
    var location: DTOLocation
}

struct DTOLocation {
    var city: String
    var country: String
}

protocol User {
    var name: String { get }
    var age: Int { get }
    var location: Location { get }
}

protocol Location {
    var city: String { get }
    var country: String { get }
}

and extend DTOLocation and DTOUser but DTOUser can't extend User protocol because User did not defined Location type named location variable

extension DTOLocation: Location {}

extension DTOUser: User {} << ERROR HERE 
// type 'DTOUser' does not conform to protocol 'User'

I want to extend DTOUser model extend User protocol how can i do it? any idea?

Hamish
  • 78,605
  • 19
  • 187
  • 280
Cruz
  • 2,602
  • 19
  • 29
  • Compare (dupe?): [Why can't a get-only property requirement in a protocol be satisfied by a property which conforms?](http://stackoverflow.com/q/42561685/2976878) – Hamish Apr 12 '17 at 11:11
  • @Hamish yes it was dupe https://bugs.swift.org/browse/SR-522 already reported bugs – Cruz Apr 12 '17 at 11:35
  • DTOUser has location as DTOLocation, and User protocol location is Location Type – ezequiel Oct 10 '18 at 11:48

0 Answers0