Declare two NSMutableArray properties (use a class instead of two NSMutableArray)
@property (strong,nonatomic) NSMutableArray *imageCollection;
@property (strong,nonatomic) NSMutableArray *songCollection;
Allocate them in viewDidLoad
self.imageCollection = [[NSMutableArray alloc] init];
self.songCollection = [[NSMutableArray alloc] init];
Add objects
[self.imageCollection addObject:@"Picture0001"];
[self.imageCollection addObject:@"Picture0002"];
[self.songCollection addObject:@"/Users/User/Library/Application Support/iPhone Simulator/5.0/Applications/7CA908BE-79DC-44EE-BEA9-A4DBF1736062/Documents/Tauky/Images/Picture0001.jpg|/Users/User/Library/Application Support/iPhone Simulator/5.0/Applications/7CA908BE-79DC-44EE-BEA9-A4DBF1736062/Documents/Tauky/Audios/song.mp3"];
[self.songCollection addObject:@"/Users/User/Library/Application Support/iPhone Simulator/5.0/Applications/7CA908BE-79DC-44EE-BEA9-A4DBF1736062/Documents/Tauky/Images/Picture0002.jpg|/Users/User/Library/Application Support/iPhone Simulator/5.0/Applications/7CA908BE-79DC-44EE-BEA9-A4DBF1736062/Documents/Tauky/Audios/song1.mp3"];
Implement UITableView
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
}
cell.textLabel.font = [UIFont systemFontOfSize:12];
NSString *imageName = [self.imageCollection objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:imageName];
cell.textLabel.text = [arry objectAtIndex:indexPath.row];
return cell;
}
Implement UitableView *didSelectRowAtIndexPath delegate*
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *songURL = [self.songCollection objectAtIndex:indexPath.row];
//play song here or pass the songURL to another controller and play it in view didload
}