@@ -13,6 +13,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
13
13
@IBOutlet var appsTableView : UITableView ?
14
14
var tableData = [ ]
15
15
var api = APIController ( )
16
+ let kCellIdentifier : String = " SearchResultCell "
16
17
17
18
override func viewDidLoad( ) {
18
19
super. viewDidLoad ( )
@@ -30,7 +31,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
30
31
}
31
32
32
33
func tableView( tableView: UITableView , cellForRowAtIndexPath indexPath: NSIndexPath ) -> UITableViewCell {
33
- let cell : UITableViewCell = UITableViewCell ( style : UITableViewCellStyle . Subtitle , reuseIdentifier : " MyTestCell " )
34
+ let cell : UITableViewCell = tableView . dequeueReusableCellWithIdentifier ( kCellIdentifier ) as UITableViewCell
34
35
35
36
let rowData : NSDictionary = self . tableData [ indexPath. row] as NSDictionary
36
37
@@ -59,6 +60,20 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
59
60
self . appsTableView!. reloadData ( )
60
61
} )
61
62
}
63
+
64
+ func tableView( tableView: UITableView , didSelectRowAtIndexPath indexPath: NSIndexPath ) {
65
+ // Get the row data for the selected row
66
+ var rowData : NSDictionary = self . tableData [ indexPath. row] as NSDictionary
67
+
68
+ var name : String = rowData [ " trackName " ] as String
69
+ var formattedPrice : String = rowData [ " formattedPrice " ] as String
70
+
71
+ var alert : UIAlertView = UIAlertView ( )
72
+ alert. title = name
73
+ alert. message = formattedPrice
74
+ alert. addButtonWithTitle ( " Ok " )
75
+ alert. show ( )
76
+ }
62
77
63
78
}
64
79
0 commit comments