0

次のiCalファイルがありますrRulerRule = "FREQ=WEEKLY;UNTIL=20140425T160000Z;INTERVAL=1;BYDAY=TU,TH";

この情報をEKEvent:

EKEvent *event;
event.recurrenceRules = ...

を分割しrRuleて保存しNSArrayます:

 NSArray * rules = [evento.rRule componentsSeparatedByString:@";"];
 event.recurrenceRules = rules;

しかし、エラーが発生します:

-[__NSCFString relationForKey:]: unrecognized selector sent to instance 0x21283350
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString relationForKey:]: unrecognized selector sent to instance 0x21283350'

手伝って頂けますか?よろしくお願いします。

4

2 に答える 2

4

EKRecurrenceRule+RRULE ライブラリを使用して解決策を見つけました。非常に使いやすいです。

リンク: https://github.com/jochenschoellig/RRULE-to-EKRecurrenceRule

使用例:

NSString *rfc2445String = @"FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2"; // The 2nd to last weekday of the month

// Result
EKRecurrenceRule *recurrenceRule = [[EKRecurrenceRule alloc] initWithString:rfc2445String];
NSLog(@"%@", recurrenceRule);
于 2014-02-17T09:40:09.533 に答える
2

文字列を配列に分割すると、文字列の配列が得られます。ただし、recurrenceRulesプロパティはオブジェクトの配列を想定していEKRecurrenceRuleます。文字列を自分で解析し、オブジェクトに変換する必要がありEKRecurrenceRuleます。複雑な繰り返しルールには、次の方法を使用する必要があります。

- (id)initRecurrenceWithFrequency:(EKRecurrenceFrequency)type interval:(NSInteger)interval daysOfTheWeek:(NSArray *)days daysOfTheMonth:(NSArray *)monthDays monthsOfTheYear:(NSArray *)months weeksOfTheYear:(NSArray *)weeksOfTheYear daysOfTheYear:(NSArray *)daysOfTheYear setPositions:(NSArray *)setPositions end:(EKRecurrenceEnd *)end

こちらのドキュメントを参照してください

于 2014-02-17T08:51:53.710 に答える