Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

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

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

イベントを追加する。

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
1
Help us understand the problem. What are the problem?