I have
class Fancy:UIButton
and I want to find all kinds of sisters that are the same class.
I'm doing it
for v:UIView in superview!.subviews { if v.isKindOfClass(Fancy) { // you may want... if (v==self) continue print("found one") (v as! Fancy).someProperty = 7 (v as! Fancy).someCall() } }
it works reliably in testing (no siblings, many, etc.)
But there are many "!" there.
Is this right in Swift?
BTW, a cool way to do this with extensions based on big answers below
Pass the type to a generic Swift extension, or ideally make it
ios swift
Fattie May 14 '16 at 10:59 p.m. 2016-05-14 22:59
source share