---
title: "Getting number of Items selected in UICollectionView in iOS."  
description: "Getting number of Items selected in UICollectionView in iOS."  
author: "Anonymous User"  
published: 2015-12-30  
updated: 2015-12-30  
canonical: https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Getting number of Items selected in UICollectionView in iOS.

I have created an [iPhone application](https://www.mindstick.com/forum/23139/can-i-embed-a-custom-font-in-an-iphone-application) using UICollectionView. I am using nsmutable [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) to [count](https://www.mindstick.com/forum/157774/selecting-count-with-distinct) multi-[selected Items](https://www.mindstick.com/forum/352/i-need-to-display-my-checkboxlist-selected-items-in-a-label-how-to-do) in our [collection view](https://www.mindstick.com/forum/33803/how-to-set-collection-view-cell-size-in-ios). I am using a lot of code only for counting.

Can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) how can I get the total number of Items selected in shortest and easiest way.

## Replies

### Reply by Tarun Kumar

[Collection](https://www.mindstick.com/articles/1718/collections-in-java) view provides a method **indexPathsForSelectedItems:** , this method helps in counting the total number of [Items](https://answers.mindstick.com/qa/47589/what-is-a-colony-committee-and-how-it-if-formed-and-what-are-the-items-fall-under-the-purview-of-colony-committee) selected in current collection view controller.\
but for doing it, it is necessary to allow collection view as multiple selection to true in the collection view method **cellForItemAtIndexPath:** , *like this*:

```
collectionView.allowsMultipleSelection = true;
```

now, to count no of selected Items in collection view use code *like this* (*here I am using it in **NSLog()***) :

```
NSLog(@"NoOfSelectedItems:%d",[collectionView.indexPathsForSelectedItems count]);
```


---

Original Source: https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
