Skip to content

Commit 5471087

Browse files
committed
Part 4
1 parent e2ae686 commit 5471087

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

TestSwift.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
026336BE193D3BB300765E31 /* Icon76.png in Resources */ = {isa = PBXBuildFile; fileRef = 026336BD193D3BB300765E31 /* Icon76.png */; };
1110
02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */; };
1211
02CCF4AA193D16930069AEE9 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */; };
1312
02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02CCF4AB193D16930069AEE9 /* Main.storyboard */; };
@@ -27,7 +26,6 @@
2726
/* End PBXContainerItemProxy section */
2827

2928
/* Begin PBXFileReference section */
30-
026336BD193D3BB300765E31 /* Icon76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon76.png; sourceTree = "<group>"; };
3129
02CCF4A2193D16930069AEE9 /* TestSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestSwift.app; sourceTree = BUILT_PRODUCTS_DIR; };
3230
02CCF4A6193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3331
02CCF4A7193D16930069AEE9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -79,7 +77,6 @@
7977
02CCF4A4193D16930069AEE9 /* TestSwift */ = {
8078
isa = PBXGroup;
8179
children = (
82-
026336BD193D3BB300765E31 /* Icon76.png */,
8380
02CCF4A7193D16930069AEE9 /* AppDelegate.swift */,
8481
02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */,
8582
02F504DA193E0B630037F599 /* APIController.swift */,
@@ -197,7 +194,6 @@
197194
files = (
198195
02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */,
199196
02CCF4AF193D16930069AEE9 /* Images.xcassets in Resources */,
200-
026336BE193D3BB300765E31 /* Icon76.png in Resources */,
201197
);
202198
runOnlyForDeploymentPostprocessing = 0;
203199
};

TestSwift/Base.lproj/Main.storyboard

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="jTM-Fb-meD">
2020
<rect key="frame" x="0.0" y="37" width="480" height="443"/>
2121
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
22+
<prototypes>
23+
<tableViewCell contentMode="scaleToFill" ambiguous="YES" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SearchResultCell" textLabel="o44-lj-tnG" detailTextLabel="f61-1K-uZN" style="IBUITableViewCellStyleSubtitle" id="8WK-Kc-W0k">
24+
<autoresizingMask key="autoresizingMask"/>
25+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8WK-Kc-W0k" id="Zn0-6L-dYn">
26+
<autoresizingMask key="autoresizingMask"/>
27+
<subviews>
28+
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="o44-lj-tnG">
29+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
30+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
31+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
32+
<nil key="highlightedColor"/>
33+
</label>
34+
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="f61-1K-uZN">
35+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
36+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
37+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
38+
<nil key="highlightedColor"/>
39+
</label>
40+
</subviews>
41+
</tableViewCellContentView>
42+
</tableViewCell>
43+
</prototypes>
2244
<connections>
2345
<outlet property="dataSource" destination="BYZ-38-t0r" id="Rph-up-PTP"/>
2446
<outlet property="delegate" destination="BYZ-38-t0r" id="zEB-7D-wXK"/>

TestSwift/Icon76.png

-7.73 KB
Binary file not shown.

TestSwift/SearchResultsViewController.swift

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import UIKit
1010

1111
class SearchResultsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, APIControllerProtocol {
1212

13+
let kCellIdentifier: String = "SearchResultCell"
14+
1315
var api: APIController = APIController()
1416
@IBOutlet var appsTableView : UITableView
1517
var tableData: NSArray = NSArray()
@@ -27,7 +29,11 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
2729

2830

2931
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
30-
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell")
32+
33+
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
34+
if cell == nil {
35+
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier)
36+
}
3137

3238
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
3339

@@ -58,4 +64,28 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa
5864
}
5965
}
6066

61-
}
67+
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
68+
69+
// Get the row data for the selected row
70+
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
71+
println(rowData)
72+
73+
var name: String = rowData["trackName"] as String
74+
var formattedPrice: String = rowData["formattedPrice"] as String
75+
76+
var alert: UIAlertView = UIAlertView()
77+
alert.title = name
78+
alert.message = formattedPrice
79+
alert.addButtonWithTitle("Ok")
80+
alert.show()
81+
82+
}
83+
84+
}
85+
86+
87+
88+
89+
90+
91+

0 commit comments

Comments
 (0)