Skip to content

Commit 913cf26

Browse files
author
Steve Trease
committed
Added UIRefreshControl to allow for pull to refresh.
Moved call to tableware.reloadData to end of data update function. Removed placeholders for IP address lookups.
1 parent 08a8ce8 commit 913cf26

File tree

2 files changed

+19
-28
lines changed

2 files changed

+19
-28
lines changed

IP Address/Base.lproj/Main.storyboard

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13528" 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="13770" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
33
<device id="retina5_5" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
7-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13526"/>
7+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13770"/>
88
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
@@ -125,9 +125,6 @@
125125
<constraint firstItem="aXX-aH-RTQ" firstAttribute="trailing" secondItem="6Tk-OE-BBY" secondAttribute="trailing" id="aEE-oa-v7a"/>
126126
</constraints>
127127
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
128-
<connections>
129-
<outletCollection property="gestureRecognizers" destination="Klv-Uj-dqg" appends="YES" id="Mkb-WH-g6K"/>
130-
</connections>
131128
</view>
132129
<connections>
133130
<outlet property="IPv4filterSwitch" destination="4D9-QY-Z7f" id="isA-GW-TSe"/>
@@ -137,11 +134,6 @@
137134
</connections>
138135
</viewController>
139136
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
140-
<tapGestureRecognizer id="Klv-Uj-dqg">
141-
<connections>
142-
<action selector="screenTappedTriggeredWithSender:" destination="BYZ-38-t0r" id="79s-02-OVl"/>
143-
</connections>
144-
</tapGestureRecognizer>
145137
</objects>
146138
</scene>
147139
</scenes>

IP Address/ViewController.swift

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,26 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
1717
@IBOutlet var linkLayerfilterSwitch: UISwitch!
1818

1919

20-
var interfaces = Interface.allInterfaces()
20+
private var interfaces = Interface.allInterfaces()
21+
private var refresher: UIRefreshControl!
2122

2223

2324
override func viewDidLoad() {
2425
super.viewDidLoad()
2526

26-
let hostname = "www.trease.eu"
27-
let dns = DNSLookup.lookup(hostname)
28-
print (hostname + ":" + dns)
27+
// setup pull to refresh
28+
refresher = UIRefreshControl()
29+
tableView.addSubview(refresher)
30+
refresher.attributedTitle = NSAttributedString (string: "Pull to refresh")
31+
refresher.addTarget(self, action: #selector(refreshAndSortAndFilterData), for: .valueChanged)
2932

30-
let ip = "8.8.8.8"
31-
let dnsName = DNSLookup.reverseLookup(ip)
32-
print (ip + ":" + dnsName)
33+
// let hostname = "www.trease.eu"
34+
// let dns = DNSLookup.lookup(hostname)
35+
// print (hostname + ":" + dns)
36+
37+
// let ip = "8.8.8.8"
38+
// let dnsName = DNSLookup.reverseLookup(ip)
39+
// print (ip + ":" + dnsName)
3340

3441
refreshAndSortAndFilterData()
3542
}
@@ -67,19 +74,10 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
6774
}
6875
}
6976
refreshAndSortAndFilterData()
70-
self.tableView.reloadData()
71-
}
72-
73-
74-
// screen tap to refresh
75-
@IBAction func screenTappedTriggered(sender: AnyObject) {
76-
print (NSURL (fileURLWithPath: "\(#file)").lastPathComponent!, "\(#function)")
77-
refreshAndSortAndFilterData()
78-
self.tableView.reloadData()
7977
}
8078

8179

82-
func refreshAndSortAndFilterData () {
80+
@objc func refreshAndSortAndFilterData () {
8381
UIApplication.shared.isNetworkActivityIndicatorVisible = true
8482

8583
interfaces = Interface.allInterfaces()
@@ -108,6 +106,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
108106
}
109107

110108
print (interfaces.count)
111-
UIApplication.shared.isNetworkActivityIndicatorVisible = false
109+
tableView.reloadData()
110+
refresher.endRefreshing()
112111
}
113112
}

0 commit comments

Comments
 (0)