-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b28955c
commit 9aac071
Showing
9 changed files
with
456 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
RRuleSwiftExample-TodayExtension/Base.lproj/MainInterface.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="M4Y-Lb-cyx"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/> | ||
</dependencies> | ||
<scenes> | ||
<!--Today View Controller--> | ||
<scene sceneID="cwh-vc-ff4"> | ||
<objects> | ||
<viewController id="M4Y-Lb-cyx" customClass="TodayViewController" customModuleProvider="target" sceneMemberID="viewController"> | ||
<layoutGuides> | ||
<viewControllerLayoutGuide type="top" id="Ft6-oW-KC0"/> | ||
<viewControllerLayoutGuide type="bottom" id="FKl-LY-JtV"/> | ||
</layoutGuides> | ||
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="37"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<subviews> | ||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="top" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hello World" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="280" translatesAutoresizingMaskIntoConstraints="NO" id="GcN-lo-r42"> | ||
<rect key="frame" x="20" y="8" width="280" height="21"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<color key="textColor" cocoaTouchSystemColor="lightTextColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
</subviews> | ||
<constraints> | ||
<constraint firstItem="FKl-LY-JtV" firstAttribute="top" secondItem="GcN-lo-r42" secondAttribute="bottom" constant="20" symbolic="YES" id="0Q0-KW-PJ6"/> | ||
<constraint firstItem="GcN-lo-r42" firstAttribute="leading" secondItem="S3S-Oj-5AN" secondAttribute="leading" constant="20" symbolic="YES" id="6Vq-gs-PHe"/> | ||
<constraint firstAttribute="trailing" secondItem="GcN-lo-r42" secondAttribute="trailing" constant="20" symbolic="YES" id="L8K-9R-egU"/> | ||
<constraint firstItem="GcN-lo-r42" firstAttribute="top" secondItem="Ft6-oW-KC0" secondAttribute="bottom" constant="20" symbolic="YES" id="mYS-Cv-VNx"/> | ||
</constraints> | ||
</view> | ||
<extendedEdge key="edgesForExtendedLayout"/> | ||
<nil key="simulatedStatusBarMetrics"/> | ||
<nil key="simulatedTopBarMetrics"/> | ||
<nil key="simulatedBottomBarMetrics"/> | ||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> | ||
<size key="freeformSize" width="320" height="37"/> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="516" y="285"/> | ||
</scene> | ||
</scenes> | ||
<simulatedMetricsContainer key="defaultSimulatedMetrics"> | ||
<simulatedStatusBarMetrics key="statusBar"/> | ||
<simulatedOrientationMetrics key="orientation"/> | ||
<simulatedScreenMetrics key="destination" type="retina4"/> | ||
</simulatedMetricsContainer> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>RRuleSwiftExample-TodayExtension</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>XPC!</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>0.0.9</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>9</string> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionMainStoryboard</key> | ||
<string>MainInterface</string> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.widget-extension</string> | ||
</dict> | ||
</dict> | ||
</plist> |
76 changes: 76 additions & 0 deletions
76
RRuleSwiftExample-TodayExtension/TodayViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// TodayViewController.swift | ||
// RRuleSwiftExample-TodayExtension | ||
// | ||
// Created by 洪鑫 on 16/6/6. | ||
// Copyright © 2016年 Teambition. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import NotificationCenter | ||
import RRuleSwift | ||
|
||
class TodayViewController: UIViewController, NCWidgetProviding { | ||
let dateFormatter: NSDateFormatter = { | ||
let dateFormatter = NSDateFormatter() | ||
dateFormatter.timeZone = NSTimeZone.defaultTimeZone() | ||
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") | ||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss EEE" | ||
return dateFormatter | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
var rule = RecurrenceRule(recurrenceWithRRuleString: "RRULE:FREQ=WEEKLY;DTSTART=20151119T014500Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR;UNTIL=20170101T014500Z")! | ||
rule.exdate = ExclusionDate(exdateString: "EXDATE:20151120T014500Z,20151123T014500Z,20151126T014500Z,20151127T014500Z,20151130T014500Z,20151201T014500Z,20151202T014500Z,20151203T014500Z,20151207T014500Z,20151210T014500Z,20151211T014500Z,20151215T014500Z,20151216T014500Z,20151217T014500Z,20151221T014500Z,20151222T014500Z,20151223T014500Z,20151228T014500Z,20151229T014500Z", unitGranularity: .Day) | ||
let date1 = dateFormatter.dateFromString("2016-06-06 00:00:00 Sun")! | ||
let date2 = dateFormatter.dateFromString("2016-12-13 00:00:00 Sun")! | ||
|
||
let occurrences1 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences2 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences3 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences4 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences5 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences6 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences7 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences8 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences9 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let occurrences10 = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
let _ = rule.occurrencesBetween(date: date1, andDate: date2) | ||
|
||
print(occurrences1) | ||
print(occurrences2) | ||
print(occurrences3) | ||
print(occurrences4) | ||
print(occurrences5) | ||
print(occurrences6) | ||
print(occurrences7) | ||
print(occurrences8) | ||
print(occurrences9) | ||
print(occurrences10) | ||
} | ||
|
||
override func didReceiveMemoryWarning() { | ||
super.didReceiveMemoryWarning() | ||
|
||
} | ||
|
||
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)) { | ||
// Perform any setup necessary in order to update the view. | ||
|
||
// If an error is encountered, use NCUpdateResult.Failed | ||
// If there's no update required, use NCUpdateResult.NoData | ||
// If there's an update, use NCUpdateResult.NewData | ||
|
||
completionHandler(NCUpdateResult.NewData) | ||
} | ||
} |
Oops, something went wrong.