Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
b884a306
Unverified
Commit
b884a306
authored
May 14, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added transaction support to Events API
parent
4bd00a90
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
Sources/iOS/Events/Events.swift
+36
-4
No files found.
Sources/iOS/Events/Events.swift
View file @
b884a306
...
@@ -107,6 +107,9 @@ public protocol EventsDelegate {
...
@@ -107,6 +107,9 @@ public protocol EventsDelegate {
@objc(Events)
@objc(Events)
open
class
Events
:
NSObject
{
open
class
Events
:
NSObject
{
/// A boolean indicating whether to commit or not.
fileprivate
var
isCommitted
=
true
/// A reference to the eventsStore.
/// A reference to the eventsStore.
fileprivate
let
eventStore
=
EKEventStore
()
fileprivate
let
eventStore
=
EKEventStore
()
...
@@ -141,6 +144,35 @@ open class Events: NSObject {
...
@@ -141,6 +144,35 @@ open class Events: NSObject {
}
}
extension
Events
{
extension
Events
{
/// Begins a storage transaction.
open
func
begin
()
{
isCommitted
=
false
}
/// Resets the storage transaction state.
open
func
reset
()
{
isCommitted
=
true
}
/// Commits the storage transaction.
open
func
commit
(
_
completion
:
((
Bool
,
Error
?)
->
Void
))
{
reset
()
var
success
=
false
var
error
:
Error
?
do
{
try
eventStore
.
commit
()
success
=
true
}
catch
let
e
{
error
=
e
}
completion
(
success
,
error
)
}
}
extension
Events
{
/**
/**
Creates a predicate for the events Array of calendars.
Creates a predicate for the events Array of calendars.
- Parameter in calendars: An optional Array of EKCalendars.
- Parameter in calendars: An optional Array of EKCalendars.
...
@@ -277,7 +309,7 @@ extension Events {
...
@@ -277,7 +309,7 @@ extension Events {
var
error
:
Error
?
var
error
:
Error
?
do
{
do
{
try
s
.
eventStore
.
saveCalendar
(
calendar
,
commit
:
true
)
try
s
.
eventStore
.
saveCalendar
(
calendar
,
commit
:
s
.
isCommitted
)
success
=
true
success
=
true
}
catch
let
e
{
}
catch
let
e
{
error
=
e
error
=
e
...
@@ -319,7 +351,7 @@ extension Events {
...
@@ -319,7 +351,7 @@ extension Events {
}
}
do
{
do
{
try
s
.
eventStore
.
removeCalendar
(
calendar
,
commit
:
true
)
try
s
.
eventStore
.
removeCalendar
(
calendar
,
commit
:
s
.
isCommitted
)
success
=
true
success
=
true
}
catch
let
e
{
}
catch
let
e
{
error
=
e
error
=
e
...
@@ -362,7 +394,7 @@ extension Events {
...
@@ -362,7 +394,7 @@ extension Events {
var
error
:
Error
?
var
error
:
Error
?
do
{
do
{
try
s
.
eventStore
.
save
(
reminder
,
commit
:
true
)
try
s
.
eventStore
.
save
(
reminder
,
commit
:
s
.
isCommitted
)
success
=
true
success
=
true
}
catch
let
e
{
}
catch
let
e
{
error
=
e
error
=
e
...
@@ -404,7 +436,7 @@ extension Events {
...
@@ -404,7 +436,7 @@ extension Events {
}
}
do
{
do
{
try
s
.
eventStore
.
remove
(
reminder
,
commit
:
true
)
try
s
.
eventStore
.
remove
(
reminder
,
commit
:
s
.
isCommitted
)
success
=
true
success
=
true
}
catch
let
e
{
}
catch
let
e
{
error
=
e
error
=
e
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment