我有UICollectionViewFlowLayout的类子类,并且已经定义了layoutAttributesForElementsInRect
方法
在内部,我试图制作一个NSMutable数组,以便可以枚举对象。
下面的代码
override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
// I get the error at this line
var attributes : NSMutableArray = super.layoutAttributesForElementsInRect(rect)
}
我不能将属性元素子类化为UICollectionViewLayoutAttributes,因为我将无法使用一个块来枚举它
最佳答案
如果您想要一个NSMutableArray,为什么不使用:
var attributes : NSMutableArray = NSMutableArray(array: super.layoutAttributesForElementsInRect(rect))
您现在的代码需要一个NSMutableArray,但是会收到一个UICollectionViewLayoutAttributes数组
关于ios - 无法转换类型[UICollectionViewLayoutAttributes]的值?到指定的类型'NSMutableArray',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36345794/