Skip to content

Commit 7bf12ed

Browse files
committed
Added "yesterday" to date grouping
1 parent ccfbd1a commit 7bf12ed

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

Swift Push/Base.lproj/Main.storyboard

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
1616
<prototypes>
1717
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="Y6V-pK-YF5" detailTextLabel="QOP-pJ-6oa" style="IBUITableViewCellStyleSubtitle" id="mta-ed-FwN">
18-
<rect key="frame" x="0.0" y="114" width="600" height="44"/>
18+
<rect key="frame" x="0.0" y="113.5" width="600" height="44"/>
1919
<autoresizingMask key="autoresizingMask"/>
2020
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="mta-ed-FwN" id="WoY-P6-9QE">
21-
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
21+
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
2222
<autoresizingMask key="autoresizingMask"/>
2323
<subviews>
2424
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Y6V-pK-YF5">
25-
<rect key="frame" x="15" y="5" width="32" height="20"/>
25+
<rect key="frame" x="15" y="6" width="31.5" height="19.5"/>
2626
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2727
<fontDescription key="fontDescription" type="system" pointSize="16"/>
2828
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
2929
<nil key="highlightedColor"/>
3030
</label>
3131
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="QOP-pJ-6oa">
32-
<rect key="frame" x="15" y="25" width="41" height="14"/>
32+
<rect key="frame" x="15" y="25.5" width="40.5" height="13.5"/>
3333
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
3434
<fontDescription key="fontDescription" type="system" pointSize="11"/>
3535
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>

Swift Push/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>291</string>
22+
<string>293</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIBackgroundModes</key>

Swift Push/PushMessages.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ class PushMessages: NSManagedObject {
2121

2222
if (dayReceived == dayToday) {
2323
return "Today"
24+
} else if (dayReceived == cal.dateByAddingUnit([.Day], value: -1, toDate: dayToday!, options: [])) {
25+
return "Yesterday"
2426
} else {
25-
return NSDateFormatter.localizedStringFromDate(dayReceived!, dateStyle: .MediumStyle, timeStyle: .NoStyle) as String
27+
return NSDateFormatter.localizedStringFromDate(dayReceived!, dateStyle: .MediumStyle, timeStyle: .NoStyle) as String
2628
}
2729
}
2830
}

Swift Push/ViewController.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,22 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
138138
tableView.endUpdates()
139139
}
140140

141+
func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {
142+
print ("didChangeSection")
143+
switch type {
144+
case .Insert:
145+
let sectionIndexSet = NSIndexSet(index: sectionIndex)
146+
self.tableView.insertSections(sectionIndexSet, withRowAnimation: UITableViewRowAnimation.Fade)
147+
case .Delete:
148+
let sectionIndexSet = NSIndexSet(index: sectionIndex)
149+
self.tableView.deleteSections(sectionIndexSet, withRowAnimation: UITableViewRowAnimation.Fade)
150+
default:
151+
""
152+
}
153+
}
154+
141155
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
156+
print ("didChangeObject")
142157
switch (type) {
143158
case .Insert:
144159
if let indexPath = newIndexPath {
@@ -160,7 +175,6 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega
160175
if let indexPath = indexPath {
161176
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
162177
}
163-
164178
if let newIndexPath = newIndexPath {
165179
tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Fade)
166180
}

0 commit comments

Comments
 (0)