Skip to content

Commit d1981ba

Browse files
author
Steve Trease
committed
Display IP addresses in tableView
1 parent 092c7a6 commit d1981ba

File tree

3 files changed

+96
-9
lines changed

3 files changed

+96
-9
lines changed

IP Address/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
"idiom" : "ipad",
8585
"size" : "83.5x83.5",
8686
"scale" : "2x"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"size" : "1024x1024",
91+
"scale" : "1x"
8792
}
8893
],
8994
"info" : {

IP Address/Base.lproj/Main.storyboard

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,77 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
7+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
58
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
69
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
710
</dependencies>
811
<scenes>
912
<!--View Controller-->
1013
<scene sceneID="tne-QT-ifu">
1114
<objects>
12-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
15+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="IP_Address" customModuleProvider="target" sceneMemberID="viewController">
1316
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
1417
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1518
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19+
<subviews>
20+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ATv-ck-YdY">
21+
<rect key="frame" x="5" y="25" width="365" height="637"/>
22+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
23+
<prototypes>
24+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="4Ib-w1-KsL" detailTextLabel="3gV-GT-tPw" style="IBUITableViewCellStyleValue1" id="wGa-uZ-JhJ">
25+
<rect key="frame" x="0.0" y="28" width="365" height="44"/>
26+
<autoresizingMask key="autoresizingMask"/>
27+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="wGa-uZ-JhJ" id="RcN-SS-HJE">
28+
<rect key="frame" x="0.0" y="0.0" width="365" height="43.5"/>
29+
<autoresizingMask key="autoresizingMask"/>
30+
<subviews>
31+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4Ib-w1-KsL">
32+
<rect key="frame" x="15" y="12" width="33.5" height="20.5"/>
33+
<autoresizingMask key="autoresizingMask"/>
34+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
35+
<nil key="textColor"/>
36+
<nil key="highlightedColor"/>
37+
</label>
38+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3gV-GT-tPw">
39+
<rect key="frame" x="306" y="12" width="44" height="20.5"/>
40+
<autoresizingMask key="autoresizingMask"/>
41+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
42+
<nil key="textColor"/>
43+
<nil key="highlightedColor"/>
44+
</label>
45+
</subviews>
46+
</tableViewCellContentView>
47+
</tableViewCell>
48+
</prototypes>
49+
<connections>
50+
<outlet property="dataSource" destination="BYZ-38-t0r" id="BYz-bj-zja"/>
51+
<outlet property="delegate" destination="BYZ-38-t0r" id="Jfu-M1-cfR"/>
52+
</connections>
53+
</tableView>
54+
</subviews>
1655
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
56+
<gestureRecognizers/>
57+
<constraints>
58+
<constraint firstItem="ATv-ck-YdY" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="5" id="5LC-ps-TmJ"/>
59+
<constraint firstItem="ATv-ck-YdY" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="5" id="7NJ-Wq-zUR"/>
60+
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="ATv-ck-YdY" secondAttribute="bottom" constant="5" id="D7m-fx-JBR"/>
61+
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="ATv-ck-YdY" secondAttribute="trailing" constant="5" id="XmI-9o-lhZ"/>
62+
</constraints>
1763
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
64+
<connections>
65+
<outletCollection property="gestureRecognizers" destination="Klv-Uj-dqg" appends="YES" id="Mkb-WH-g6K"/>
66+
</connections>
1867
</view>
1968
</viewController>
2069
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
70+
<tapGestureRecognizer id="Klv-Uj-dqg">
71+
<connections>
72+
<action selector="screenTappedTriggeredWithSender:" destination="BYZ-38-t0r" id="79s-02-OVl"/>
73+
</connections>
74+
</tapGestureRecognizer>
2175
</objects>
2276
</scene>
2377
</scenes>

IP Address/ViewController.swift

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,51 @@
99
import UIKit
1010

1111

12-
class ViewController: UIViewController {
12+
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
13+
14+
@IBOutlet var tableView: UITableView!
15+
16+
var interfaces = Interface.allInterfaces()
1317

1418
override func viewDidLoad() {
1519
super.viewDidLoad()
1620

17-
let interfaces = Interface.allInterfaces()
21+
// interfaces = Interface.allInterfaces()
1822
print (interfaces.count)
1923

20-
for interface in interfaces {
21-
print (interface.description, interface.address)
22-
}
23-
2424
// Do any additional setup after loading the view, typically from a nib.
2525
}
26+
2627

2728
override func didReceiveMemoryWarning() {
2829
super.didReceiveMemoryWarning()
2930
// Dispose of any resources that can be recreated.
3031
}
32+
33+
34+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
35+
print (interfaces.count)
36+
return interfaces.count
37+
}
38+
39+
40+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
41+
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
42+
43+
print ("cell - \(indexPath.row)")
44+
45+
cell.textLabel?.text = interfaces[indexPath.row].description
46+
cell.detailTextLabel?.text = interfaces[indexPath.row].address
47+
48+
return cell
49+
}
50+
51+
52+
// screen tap to refresh
53+
@IBAction func screenTappedTriggered(sender: AnyObject) {
54+
print (NSURL (fileURLWithPath: "\(#file)").lastPathComponent!, "\(#function)")
55+
interfaces = Interface.allInterfaces()
56+
print (interfaces.count)
57+
self.tableView.reloadData()
58+
}
3159
}

0 commit comments

Comments
 (0)