Skip to content

Commit 898961c

Browse files
stevetreaseSteve Trease
authored andcommitted
Added search back.
1 parent 0f350bd commit 898961c

File tree

6 files changed

+68
-13
lines changed

6 files changed

+68
-13
lines changed

Swift Push 4/Base.lproj/LaunchScreen.storyboard

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8076" systemVersion="14D121" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8187.4" systemVersion="15A279b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8063"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8151.3"/>
55
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
66
</dependencies>
77
<scenes>
@@ -19,17 +19,20 @@
1919
<subviews>
2020
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright © 2015 Steve Trease. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
2121
<rect key="frame" x="20" y="559" width="560" height="21"/>
22+
<animations/>
2223
<fontDescription key="fontDescription" type="system" pointSize="17"/>
2324
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
2425
<nil key="highlightedColor"/>
2526
</label>
2627
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Swift Push 4" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
2728
<rect key="frame" x="20" y="180" width="560" height="43"/>
29+
<animations/>
2830
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
2931
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
3032
<nil key="highlightedColor"/>
3133
</label>
3234
</subviews>
35+
<animations/>
3336
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
3437
<constraints>
3538
<constraint firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>

Swift Push 4/Base.lproj/Main.storyboard

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8152.3" systemVersion="15A216g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="nIE-zw-TiR">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8187.4" systemVersion="15A279b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="nIE-zw-TiR">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8124.4"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8151.3"/>
55
</dependencies>
66
<scenes>
77
<!--Navigation Controller-->
@@ -30,9 +30,18 @@
3030
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3131
<animations/>
3232
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
33+
<searchBar key="tableHeaderView" contentMode="redraw" showsCancelButton="YES" id="Q08-01-f5b">
34+
<rect key="frame" x="0.0" y="64" width="600" height="44"/>
35+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
36+
<animations/>
37+
<textInputTraits key="textInputTraits"/>
38+
<connections>
39+
<outlet property="delegate" destination="7bK-jq-Zjz" id="UMO-9S-oP0"/>
40+
</connections>
41+
</searchBar>
3342
<prototypes>
3443
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="Arm-wq-HPj" detailTextLabel="su6-nF-v8b" style="IBUITableViewCellStyleSubtitle" id="WCw-Qf-5nD">
35-
<rect key="frame" x="0.0" y="86" width="600" height="44"/>
44+
<rect key="frame" x="0.0" y="130" width="600" height="44"/>
3645
<autoresizingMask key="autoresizingMask"/>
3746
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="WCw-Qf-5nD" id="37f-cq-3Eg">
3847
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
@@ -43,15 +52,15 @@
4352
<autoresizingMask key="autoresizingMask"/>
4453
<animations/>
4554
<fontDescription key="fontDescription" type="system" pointSize="16"/>
46-
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
55+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
4756
<nil key="highlightedColor"/>
4857
</label>
4958
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="su6-nF-v8b">
50-
<rect key="frame" x="15" y="25.5" width="41" height="13.5"/>
59+
<rect key="frame" x="15" y="25.5" width="40.5" height="13.5"/>
5160
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
5261
<animations/>
5362
<fontDescription key="fontDescription" type="system" pointSize="11"/>
54-
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
63+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
5564
<nil key="highlightedColor"/>
5665
</label>
5766
</subviews>
@@ -69,7 +78,7 @@
6978
</tableView>
7079
<navigationItem key="navigationItem" title="Swift Push" id="Zdf-7t-Un8"/>
7180
<connections>
72-
<outlet property="searchDisplayController" destination="c5m-kZ-LXa" id="2Ot-2Q-pjS"/>
81+
<outlet property="searchDisplayController" destination="dxw-He-NIa" id="oCl-pX-9er"/>
7382
</connections>
7483
</tableViewController>
7584
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
@@ -81,6 +90,15 @@
8190
<outlet property="searchResultsDelegate" destination="7bK-jq-Zjz" id="gUd-Rh-HoR"/>
8291
</connections>
8392
</searchDisplayController>
93+
<searchDisplayController id="dxw-He-NIa">
94+
<connections>
95+
<outlet property="delegate" destination="7bK-jq-Zjz" id="vbG-y6-3ZK"/>
96+
<outlet property="searchBar" destination="Q08-01-f5b" id="WKA-yO-YDY"/>
97+
<outlet property="searchContentsController" destination="7bK-jq-Zjz" id="s5x-aM-s8f"/>
98+
<outlet property="searchResultsDataSource" destination="7bK-jq-Zjz" id="FTk-zh-qN3"/>
99+
<outlet property="searchResultsDelegate" destination="7bK-jq-Zjz" id="r0K-OC-dt5"/>
100+
</connections>
101+
</searchDisplayController>
84102
</objects>
85103
<point key="canvasLocation" x="181" y="-404"/>
86104
</scene>

Swift Push 4/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>542</string>
22+
<string>543</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIBackgroundModes</key>

Swift Push 4/MasterViewController.swift

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import UIKit
1010

11-
class MasterViewController: UITableViewController {
11+
class MasterViewController: UITableViewController, UISearchBarDelegate, UISearchDisplayDelegate {
1212

1313
override func viewDidLoad() {
1414
super.viewDidLoad()
@@ -24,6 +24,28 @@ class MasterViewController: UITableViewController {
2424
self.tableView.rowHeight = UITableViewAutomaticDimension
2525
}
2626

27+
28+
var filteredNotifications = [NotificationData]()
29+
30+
func filterContentForSearchText(searchText: String) {
31+
// Filter the array using the filter method
32+
self.filteredNotifications = notifications.filter({( notification: NotificationData) -> Bool in
33+
// let categoryMatch = (scope == "All") || (notification.alert == scope)
34+
let stringMatch = notification.alert.rangeOfString(searchText)
35+
return (stringMatch != nil)
36+
})
37+
}
38+
func searchDisplayController(controller: UISearchDisplayController, shouldReloadTableForSearchString searchString: String?) -> Bool {
39+
self.filterContentForSearchText(searchString!)
40+
return true
41+
}
42+
43+
func searchDisplayController(controller: UISearchDisplayController, shouldReloadTableForSearchScope searchOption: Int) -> Bool {
44+
self.filterContentForSearchText(self.searchDisplayController!.searchBar.text!)
45+
return true
46+
}
47+
48+
2749
override func didReceiveMemoryWarning() {
2850
super.didReceiveMemoryWarning()
2951
// Dispose of any resources that can be recreated.
@@ -41,7 +63,13 @@ class MasterViewController: UITableViewController {
4163
}
4264

4365
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
44-
return notifications.count
66+
if tableView == self.searchDisplayController!.searchResultsTableView {
67+
print("filtered ")
68+
return self.filteredNotifications.count
69+
} else {
70+
print("unfiltered ")
71+
return notifications.count
72+
}
4573
}
4674

4775
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
@@ -50,6 +78,12 @@ class MasterViewController: UITableViewController {
5078

5179
notification = notifications[indexPath.row]
5280

81+
if tableView == self.searchDisplayController!.searchResultsTableView {
82+
notification = filteredNotifications[indexPath.row]
83+
} else {
84+
notification = notifications[indexPath.row]
85+
}
86+
5387
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
5488

5589
cell.layer.masksToBounds = true

Swift Push 4/Settings.bundle/Root.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<array>
77
<dict>
88
<key>DefaultValue</key>
9-
<string>542</string>
9+
<string>543</string>
1010
<key>Key</key>
1111
<string>CurrentBuildNumber</string>
1212
<key>Title</key>

0 commit comments

Comments
 (0)