3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CocoaAdvent Calendar 2017

Day 18

[macOS][iOS]EventKitを試す(イベントの追加と削除)

Last updated at Posted at 2017-12-17

前回の続きで、イベントの追加と削除を試す。

イベントを追加する。

let event = EKEvent(eventStore: store)
event.title = "BUKURO.swift 2017-12"
event.startDate = Calendar.current.date(from: DateComponents(year: 2017, month: 12, day: 6, hour: 19, minute: 30, second: 00))
event.endDate = Calendar.current.date(from: DateComponents(year: 2017, month: 12, day: 6, hour: 22, minute: 00, second: 00))
event.calendar = store.defaultCalendarForNewEvents
do {
    try store.save(event, span: .thisEvent)
}
catch let error {
    print(error)
}

イベントを削除する。

do {
    try store.remove(event, span: .thisEvent)
}
catch let error {
    print(error)
}

動作確認が原因で関係者に通知が飛んでしまった。申し訳ない。

ソースコード
GitHubからどうぞ。

https://github.com/murakami/workbook/tree/master/ios/GettingThingsDone - GitHub

関連情報
Cocoa勉強会 BUKURO.swift (connpass)

Cocoa勉強会 BUKURO.swift (ATND)

Cocoa勉強会 BUKURO.swift (Peatix)

【Cocoa練習帳】
http://www.bitz.co.jp/weblog/

http://ameblo.jp/bitz/(ミラー・サイト)

Qiita

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?