Skip to content

Commit 1add14d

Browse files
committed
Create TrackCell
1 parent cf07dd9 commit 1add14d

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

TestSwift/Base.lproj/Main.storyboard

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6154.17" systemVersion="13D65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="18C-lM-Kii">
33
<dependencies>
4+
<deployment defaultVersion="1536" identifier="iOS"/>
45
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6153.11"/>
56
</dependencies>
67
<scenes>
@@ -111,6 +112,46 @@
111112
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="0Il-Wa-ILq">
112113
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
113114
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
115+
<prototypes>
116+
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="TrackCell" id="q8P-5k-V04">
117+
<autoresizingMask key="autoresizingMask"/>
118+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="q8P-5k-V04" id="Hvr-uO-kzf">
119+
<autoresizingMask key="autoresizingMask"/>
120+
<subviews>
121+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dE4-MC-wkr">
122+
<rect key="frame" x="-23" y="-15" width="46" height="30"/>
123+
<state key="normal" title="▶️">
124+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
125+
</state>
126+
<variation key="heightClass=regular-widthClass=compact" fixedFrame="YES">
127+
<rect key="frame" x="20" y="7" width="30" height="30"/>
128+
</variation>
129+
</button>
130+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.25" translatesAutoresizingMaskIntoConstraints="NO" id="DPO-xR-L6h">
131+
<rect key="frame" x="0.0" y="-21" width="42" height="21"/>
132+
<fontDescription key="fontDescription" name="HelveticaNeue-Thin" family="Helvetica Neue" pointSize="18"/>
133+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
134+
<nil key="highlightedColor"/>
135+
<variation key="heightClass=regular-widthClass=compact" fixedFrame="YES">
136+
<rect key="frame" x="58" y="7" width="208" height="33"/>
137+
</variation>
138+
</label>
139+
</subviews>
140+
<variation key="default">
141+
<mask key="subviews">
142+
<exclude reference="dE4-MC-wkr"/>
143+
<exclude reference="DPO-xR-L6h"/>
144+
</mask>
145+
</variation>
146+
<variation key="heightClass=regular-widthClass=compact">
147+
<mask key="subviews">
148+
<include reference="dE4-MC-wkr"/>
149+
<include reference="DPO-xR-L6h"/>
150+
</mask>
151+
</variation>
152+
</tableViewCellContentView>
153+
</tableViewCell>
154+
</prototypes>
114155
<variation key="widthClass=compact" fixedFrame="YES">
115156
<rect key="frame" x="20" y="179" width="280" height="281"/>
116157
</variation>
@@ -156,11 +197,12 @@
156197
<connections>
157198
<outlet property="albumCover" destination="vzM-nB-nVu" id="9LD-H2-2p1"/>
158199
<outlet property="titleLabel" destination="X4G-YW-dpA" id="91I-eF-tB4"/>
200+
<outlet property="tracksTableView" destination="0Il-Wa-ILq" id="Zl6-tj-Pea"/>
159201
</connections>
160202
</viewController>
161203
<placeholder placeholderIdentifier="IBFirstResponder" id="jMh-ub-mcV" userLabel="First Responder" sceneMemberID="firstResponder"/>
162204
</objects>
163-
<point key="canvasLocation" x="891" y="183"/>
205+
<point key="canvasLocation" x="891" y="180"/>
164206
</scene>
165207
<!--Navigation Controller-->
166208
<scene sceneID="YYH-df-0Po">

TestSwift/Classes/Album.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ class Album {
2525
self.artistURL = artistURL
2626
self.collectionId = collectionId
2727
}
28+
2829
}

TestSwift/Classes/DetailsViewController.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class DetailsViewController: UIViewController, UITableViewDelegate, UITableViewD
1212

1313
@IBOutlet var albumCover : UIImageView
1414
@IBOutlet var titleLabel : UILabel
15+
@IBOutlet var tracksTableView : UITableView
1516

1617
var album: Album?
1718
var tracks: Track[] = []
@@ -36,11 +37,19 @@ class DetailsViewController: UIViewController, UITableViewDelegate, UITableViewD
3637

3738
func didRecieveAPIResults(results: NSDictionary) {
3839
println("Got track deets \(results)")
40+
if let allResults = results["results"] as? NSDictionary[] {
41+
for trackInfo in allResults {
42+
// Create the track
43+
var track = Track(dict: trackInfo)
44+
tracks.append(track)
45+
}
46+
}
47+
tracksTableView.reloadData()
3948
}
4049

4150

4251
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
43-
return 0
52+
return tracks.count
4453
}
4554

4655
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {

TestSwift/Classes/Track.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ class Track {
1717
self.price = price
1818
self.previewUrl = previewUrl
1919
}
20+
21+
init(dict: NSDictionary!) {
22+
23+
}
24+
2025
}

0 commit comments

Comments
 (0)