title: layoutAttributesForElements function from swift 2 gives error warning
body: <p>I am converting my project from swift 2 to swift 3, and I have difficulties understanding what's wrong with the following function:</p>
  
  <pre><code>override func layoutAttributesForElements(in rect: CGRect) -&gt; [UICollectionViewLayoutAttributes]? {
     var attributes = [UICollectionViewLayoutAttributes]()
      if self.itemAttributes != nil {
          for section in self.itemAttributes {
  
              let filteredArray  =  (section as AnyObject).filtered(
  
                  using: NSPredicate { (evaluatedObject, bindings) -&gt; Bool in
                      return rect.intersects(evaluatedObject.frame)
                  }
              ) as! [UICollectionViewLayoutAttributes]
  
              attributes.append(contentsOf: filteredArray)
  
          }
      }
  
     return attributes
  }
  </code></pre>
  
  <p><code>self.itemAttributes</code> is a class property defined as:</p>
  
  <p><code>var itemAttributes : NSMutableArray!</code></p>
  
  <p><code>sectionAttributes</code> is set in another function:</p>
  
  <pre><code>override func prepare() {
    if self.collectionView?.numberOfSections == 0 {
          return
      }
  
      if (self.itemAttributes != nil &amp;&amp; self.itemAttributes.count &gt; 0) {
          for section in 0..&lt;self.collectionView!.numberOfSections {
              let numberOfItems : Int = self.collectionView!.numberOfItems(inSection: section)
             for index in 0..&lt;numberOfItems {
                  if section != 0 &amp;&amp; index != 0 {
                      continue
                  }
  
                  let attributes : UICollectionViewLayoutAttributes = self.layoutAttributesForItem(at: IndexPath(item: index, section: section))!
                  if section == 0 {
                      var frame = attributes.frame
                      frame.origin.y = self.collectionView!.contentOffset.y
                      attributes.frame = frame
                  }
  
                  if index == 0 {
                      var frame = attributes.frame
                      frame.origin.x = self.collectionView!.contentOffset.x
                      attributes.frame = frame
                  }
              }
          }
          return
      }
  
      if (self.itemsSize == nil || self.itemsSize.count != numberOfColumns) {
          self.calculateItemsSize()
      }
  
      var column = 0
      var xOffset : CGFloat = 0
      var yOffset : CGFloat = 0
      var contentWidth : CGFloat = 0
      var contentHeight : CGFloat = 0
  
      for section in 0..&lt;self.collectionView!.numberOfSections {
          let sectionAttributes = NSMutableArray()
  
          for index in 0..&lt;numberOfColumns {
              let itemSize = (self.itemsSize[index] as AnyObject).cgSizeValue
              let indexPath = IndexPath(item: index, section: section)
              let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath)
              attributes.frame = CGRect(x: xOffset, y: yOffset, width: (itemSize?.width)!, height: (itemSize?.height)!).integral
  
              if section == 0 &amp;&amp; index == 0 {
                  attributes.zIndex = 1024;
              } else  if section == 0 || index == 0 {
                  attributes.zIndex = 1023
              }
  
              if section == 0 {
                  var frame = attributes.frame
                  frame.origin.y = self.collectionView!.contentOffset.y
                  attributes.frame = frame
              }
              if index == 0 {
                  var frame = attributes.frame
                  frame.origin.x = self.collectionView!.contentOffset.x
                  attributes.frame = frame
              }
  
              sectionAttributes.add(attributes)
  
              xOffset += (itemSize?.width)!
              column += 1
  
              if column == numberOfColumns {
                  if xOffset &gt; contentWidth {
                      contentWidth = xOffset
                  }
  
                  column = 0
                  xOffset = 0
                  yOffset += (itemSize?.height)!
              }
          }
          if (self.itemAttributes == nil) {
              self.itemAttributes = NSMutableArray(capacity: self.collectionView!.numberOfSections)
          }
          self.itemAttributes .add(sectionAttributes)
      }
  
      let attributes : UICollectionViewLayoutAttributes = (self.itemAttributes.lastObject as AnyObject).lastObject as! UICollectionViewLayoutAttributes
      contentHeight = attributes.frame.origin.y + attributes.frame.size.height
      self.contentSize = CGSize(width: contentWidth, height: contentHeight)}
  </code></pre>
  
  <p>Xcode throws a <code>Type of expression is ambiguous without more context</code>
  for the <code>layoutAttributesForElements</code> function in the <code>return rect.intersects(evaluatedObject.frame)</code> line</p>