Можно ли добавить кортеж подтипа в массив кортежей типа в Swift? - PullRequest
0 голосов
/ 20 октября 2018

Я хочу объявить эту константу:

let simultaneousGestures: [(UIGestureRecognizer.Type, UIGestureRecognizer.Type)] = 
    [(UIPanGestureRecognizer, UIPinchGestureRecognizer), 
     (UIPanGestureRecognizer, UIRotationGestureRecognizer), 
     (UIPinchGestureRecognizer, UIRotationGestureRecognizer), 
     (UIPinchGestureRecognizer, UIPanGestureRecognizer),      
     (UIRotationGestureRecognizer, UIPanGestureRecognizer), 
     (UIRotationGestureRecognizer, UIPinchGestureRecognizer)
    ]

Но я получаю эту ошибку:

Cannot convert value of type '(UIPanGestureRecognizer, UIPinchGestureRecognizer).Type' to expected element type '(UIGestureRecognizer.Type, UIGestureRecognizer.Type)'

Как мне этого добиться?

1 Ответ

0 голосов
/ 20 октября 2018

Вы должны написать

let simultaneousGestures: [(UIGestureRecognizer.Type, UIGestureRecognizer.Type)] =
    [(UIPanGestureRecognizer.self, UIPinchGestureRecognizer.self),
     (UIPanGestureRecognizer.self, UIRotationGestureRecognizer.self),
     (UIPinchGestureRecognizer.self, UIRotationGestureRecognizer.self),
     (UIPinchGestureRecognizer.self, UIPanGestureRecognizer.self),
     (UIRotationGestureRecognizer.self, UIPanGestureRecognizer.self),
     (UIRotationGestureRecognizer.self, UIPinchGestureRecognizer.self)
]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...