Right now I'm using NSClassFromString
, but is there a better way to get an AnyClass
! from a class in Swift? I am trying to pass the reference to my collection view's -registerClass:forCellWithReuseIdentifier:
method.
collectionView.registerClass(NSClassFromString("MyCoolViewCell"), forCellWithReuseIdentifier: "MyCoolViewCell")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…