childrenOurFuture childrenOurFuture - 6 months ago 3x
Swift Question

Swift grammar: what the usage of [CGFloat: [UICollectionViewLayoutAttributes]]()?

I am reading some code from a open source project which is using swift. Here I come across the code

[CGFloat: [UICollectionViewLayoutAttributes]]()
, and I don't understand the usage of the code and I even don't know how to google it.(what's the key word?)

My question is focus on the
[CGFloat: [UICollectionViewLayoutAttributes]]()
, what the usage or how to understand it?

And below is the code in context.

override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let layoutAttributes = super.layoutAttributesForElementsInRect(rect)
var rowCollections = [CGFloat: [UICollectionViewLayoutAttributes]]()

...... // not concerned with the question


It's a Dictionary whose keys are of type CGFloat and whose values are of type [UICollectionViewLayoutAttributes] (also known as Array<UICollectionViewLayoutAttributes>).