ios7 - Identifier for individual UITableViewCell? -


I am trying to create a really simple app that shows a list of songs in the UITT footage. The user can then select a song and the song will start playing. I have not implemented AVAudioPlayer yet I do not want to deal with him yet. For now, I'm just using the test NSLog statement to test the tableView: didSelectRowAtIndexPath: method. Here is my code

  - (zero) tableview: (UITableView *) table view was selected Select Endpath: (NSIndexPath *) IndexPath {if (indexPath.section == 0) {switch (indexPath .row) {case 0: NSLog (@ "Play Play"); break; Case 1: NSLog (@ "Play That Young"); break; Case 2: NSLog (@ "Play Zombie Soc"); Default: Break; }} And {Uh oh I have not created this section.}}  

Note that these cells were programmatic, I have a prototype cell in the interface builder And these three were programmatically created. These static cells are not dynamic cells.

I believe this should be a better way of doing this. If I change the order of any of these cells then NSLog statement will not match UILB to the cell? What is the better way to code this? Probably create a string ID for each cell but then where should I store the string id? Should I store it as a @property of TableViewCell.h? How do you create an identifier for each cell?

I have seen a very good solution but I can not use it because I do not have a stable cell to make IBotllet.

Instead of using the information in the cell used in that method - (zero ) Table view: (UITableView *) table view was SelectionRowAtIndexPath: (NSIndexPath *) indexPath

For example in custom cell you have to store somethingthing, songName, and songPath ) It's just an example, I'm outlining in a custom cell for labels, I took the stars that were in the cell by the labels. Will be used
@interface CustomCell: UITableViewCell @property (nonatomic, retain) NSString * SongName; // song name @ property (nontamic, write) NSString * SongPath; // It can help to locate your song by putting it to keep


- (zero) table view: (UITableView *) tableview was done by SelectionRowAtIndexPath: (NSIndexPath *) indexPath {CustomCell * cell = (CustomCell *) [TableView CellForraArtIntexpath: IndexPath]; // You can get CL after re-arranging all related attributes and all associated properties for cell NSString * songName = cell.SongName; NSLog (@ "% @", songName); // Suppose you want to use the information in the cell, then // cell. Songpath - & gt; The URL returns (the location of the file) for it paly}}



Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -