Skip to content

Commit

Permalink
add api to set endlessRecurrenceCount
Browse files Browse the repository at this point in the history
  • Loading branch information
hongxinhope committed May 20, 2016
1 parent 3699c44 commit b28955c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions RRuleSwift/Generators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ internal struct Generator {
}

public extension RecurrenceRule {
public func allOccurrences() -> [NSDate] {
public func allOccurrences(endlessRecurrenceCount: Int = Generator.endlessRecurrenceCount) -> [NSDate] {
guard let rrulejs = JavaScriptBridge.rrulejs() else {
return []
}

let ruleJSONString = toJSONString()
let ruleJSONString = toJSONString(endlessRecurrenceCount: endlessRecurrenceCount)
let context = JSContext()
context.exceptionHandler = { context, exception in
print("[RRuleSwift] rrule.js error: \(exception)")
Expand Down Expand Up @@ -50,7 +50,7 @@ public extension RecurrenceRule {
return occurrences.sort { $0.isBeforeOrSameWith($1) }
}

public func occurrencesBetween(date date: NSDate, andDate otherDate: NSDate) -> [NSDate] {
public func occurrencesBetween(date date: NSDate, andDate otherDate: NSDate, endlessRecurrenceCount: Int = Generator.endlessRecurrenceCount) -> [NSDate] {
guard let rrulejs = JavaScriptBridge.rrulejs() else {
return []
}
Expand All @@ -60,7 +60,7 @@ public extension RecurrenceRule {
let beginDateJSON = RRule.ISO8601DateFormatter.stringFromDate(beginDate)
let untilDateJSON = RRule.ISO8601DateFormatter.stringFromDate(untilDate)

let ruleJSONString = toJSONString()
let ruleJSONString = toJSONString(endlessRecurrenceCount: endlessRecurrenceCount)
let context = JSContext()
context.exceptionHandler = { context, exception in
print("[RRuleSwift] rrule.js error: \(exception)")
Expand Down
4 changes: 2 additions & 2 deletions RRuleSwift/JavaScriptBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal extension EKWeekday {
}

internal extension RecurrenceRule {
internal func toJSONString() -> String {
internal func toJSONString(endlessRecurrenceCount endlessRecurrenceCount: Int) -> String {
var jsonString = "freq: \(frequency.toJSONFrequency()),"
jsonString += "interval: \(max(1, interval)),"
jsonString += "wkst: \(firstDayOfWeek.toJSONSymbol()),"
Expand All @@ -65,7 +65,7 @@ internal extension RecurrenceRule {
} else if let count = recurrenceEnd?.occurrenceCount {
jsonString += "count: \(count),"
} else {
jsonString += "count: \(Generator.endlessRecurrenceCount),"
jsonString += "count: \(endlessRecurrenceCount),"
}

let bysetposStrings = bysetpos.flatMap({ (setpo) -> String? in
Expand Down
2 changes: 1 addition & 1 deletion RRuleSwift/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.7</string>
<string>0.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions RRuleSwiftExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.7</string>
<string>0.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>7</string>
<string>8</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down

0 comments on commit b28955c

Please sign in to comment.