I have loaded images and labels to custom collectionview cells in this method
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
Giving the cells title based on actual NSIndexPath value in the same method
cell.label.text = [NSString stringWithFormat:@"{%ld,%ld}", (long)indexPath.row, (long)indexPath.section];
Loading different images in each cell of the custom collection view cells in the same method
NSString *imageToLoad = [NSString stringWithFormat:@"%d.jpg", indexPath.row];
cell.image.image = [UIImage imageNamed:imageToLoad];
I want to load different audio files in each cell of the custom collection view cells in the same method
audioArray =[[NSArray alloc] initWithObjects:@"Theme1", @"Theme2", @"Theme3", @"Theme4", nil];
NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:filePath ofType: @"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: audioFilePath];
audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:fileURL error:nil];
If i add indexPath.row below
NSString *filePath = [audioArray objectAtIndex:indexPath.row];
Then it always plays "Theme4" last audio file from within the array in all cells
And if i write 0
NSString *filePath = [audioArray objectAtIndex:0];
Then it plays always "Theme1" the very first audio file in all cells
How i can load different audio files in each cell of the custom collection view cells.
Thanks for help.