<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionView/frameForItem(at:withNumberOfItems:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionView(im)frameForItemAtIndex:withNumberOfItems:"
  },
  "title" : "frameForItem(at:withNumberOfItems:)"
}
-->

# frameForItem(at:withNumberOfItems:)

Returns the frame of an item based on the number of items in the collection view.

```
func frameForItem(at index: Int, withNumberOfItems numberOfItems: Int) -> NSRect
```

## Parameters

`index`

The index of the item in the collection view.

`numberOfItems`

The targeted number of items in the collection view. Use this parameter to specify the number of items you intend to have in the collection view, if that number is different than the actual number of items.

## Return Value

The frame rectangle that reflects where the collection view would place the item.

## Discussion

Using the value in the `numberOfItems` parameter, this method calculates the frame rectangle of the item at the specified `index` in the collection view.

When the collection view is a drag destination, use this method (instead of the [`content`](/documentation/AppKit/NSCollectionView/content) method) to get the frame of items. Drag operations can change the number of items, which affects the layout of the item views.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)