狠狠撸

狠狠撸Share a Scribd company logo
"リマインダー"の繰り返しを
自由に設定する

Cocoa勉強会	#64	/	2014-02-08	/	木村渡

Powered by Rabbit 2.1.1 and COZMIXNG
リマインダー

http://support.apple.com/kb/HT4970?
viewlocale=ja_JP
リマインダー
iOS/OS Xの標準アプリ
指定の期日にアラーム/通知
iCloudやiTunes経由で同期できる
これでタスク管理をしようとすると
「むきー!」となるので注意
背景
iOS7になってからリマインダーを使
いはじめた。
「3週間ごとの繰り返し」を設定し
たいモノができた。
既定の繰り返しからしか選べない?
背景
EventKit
第55回の発表参照。
カレンダーとリマインダーへのアクセ
スを提供するフレームワーク。
Calendar and Reminders Programming Guide
(Mac Developer Library)
邦訳	カレンダーとリマインダーのプログラミングガイド
EKRecurrenceRule
EKRecurrenceFrequency
interval
Days of the Week
どうみても、いろんな繰り返しが指定
できそう。
EKRecurrenceRule
ドキュメントを見た感じではさまざま
な設定が可能。
実際に試して、確認する必要がある。
現在利用可能なもの以外の繰り返し
の指定を受け入れるか。
リマインダーアプリがその繰り返し
で動作するか。
EventKit超概要(リマインダー)
このような階層になっている。
EKEventStore - リマインダー	or イ
ベント
EKCalendar - "ビジネス"、"買い
物"などの種類。
EKReminder - 個々のリマインダー
RubyCocoa+irbで試してみる
% irb1.8 -rosx/cocoa --simple-prompt
>> include OSX
>> require_framework 'EventKit'

※デモはirbでなくpryです。
ストアとカレンダーを取得
>> store =
EKEventStore.alloc.
initWithAccessToEntityTypes(
EKEntityTypeReminder)
>> calendars =
store.calendarsForEntityType(
EKEntityTypeReminder)
>> calendar = calendars.find {|cal|
cal.title == "テストだよ!"}
新規のリマインダーを作成

>> reminder = EKReminder.
reminderWithEventStore(store)
>> reminder.title = "3週間ごとに実?する!
>> reminder.calendar = calendar
リマインダー期限を設定

>> due_date = NSDateComponents.alloc.i
>> due_date.year = 2014;
due_date.month = 2;
due_date.day = 8
>> due_date.hour = 18;
due_date.minute = 30
>> reminder.dueDateComponents = due_da

NSDateでいいじゃん…
3週間ごとの繰り返しを作成

>> rule = EKRecurrenceRule.alloc.
initRecurrenceWithFrequency_inter
end(EKRecurrenceFrequencyWeekly,
3, nil)
>> reminder.addRecurrenceRule(rule)
保存する
>> result, err = store.saveReminder_
commit_error(reminder, true)
=> [true, nil]
アプリで确认。
3週間ごとになっているかを確認
完了させて次の繰り返しへ。
3週間ごとになっているかを確認
もう一度。

3週間ごとになってる!
いろんな設定を試してみる
EKRecurrenceRuleの長ーいイニシャ
ライザ。array渡す。
initRecurrenceWithFrequency:
interval:
daysOfTheWeek:daysOfTheMonth:
monthsOfTheYear:weeksOfTheYear:
daysOfTheYear:
setPositions:end:
月2回(15日,	月末)
frequency:
EKRecurrenceFrequencyMonthly
daysOfTheMonth: [15, -1]
毎月第1、第3水曜日
frequency:
EKRecurrenceFrequencyMonthly
daysOfTheWeek:
EKRecurrenceDayOfWeek.dayOfW
eek_weekNumber(4, 1),..
まとめとか感想とか
プログラムからはかなり自由に繰り
返しを設定できる。
ただしアプリの表示は「カスタムの
繰り返しパターン」に。
まとめとか感想とか
RubyCocoa便利ですよ!(宣伝)
10.5 Leopard以降のOS Xに標準イ
ンストール済み。
irb/pryで対話的に試行錯誤でき
る。コンパイル不要。
ruby 2.0や2.1への対応作业中…
終

Powered by Rabbit 2.1.1 and COZMIXNG

More Related Content

リマインダーの繰り返しを自由に設定する (EventKit)