RACalendarEventManager.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // RACalendarEventManager.h
  3. // Calendar
  4. //
  5. // Created by Jack on 2018/11/21.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class EKEvent,EKCalendar,EKAlarm;
  10. typedef void(^fetchEventCompletionBlk)(NSArray<EKEvent *> *events);
  11. typedef void(^commitResultBlk)(BOOL result, NSError *error);
  12. typedef void(^authorizeBlk)(BOOL granted);
  13. /**
  14. * Privacy - Calendars Usage Description
  15. */
  16. @interface RACalendarEventManager : NSObject
  17. @property (nonatomic,assign,readonly) BOOL authorized;
  18. + (instancetype)sharedManager;
  19. - (void)requestAuthorization:(authorizeBlk)blk;
  20. #pragma mark - 检索
  21. /**
  22. * 异步执行
  23. */
  24. - (void)eventsWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate completion:(fetchEventCompletionBlk)blk;
  25. - (EKEvent *)eventWithIdentifier:(NSString *)identifier;
  26. #pragma mark - 创建/编辑事件
  27. - (EKEvent *)createNewCalendarEvent;
  28. - (void)setTitle:(NSString *)title forEvent:(EKEvent *)event;
  29. - (void)setNotes:(NSString *)notes forEvent:(EKEvent *)event;
  30. - (void)setTimeZone:(NSTimeZone *)timeZone forEvent:(EKEvent *)event;
  31. - (void)setStartDate:(NSDate *)startDate forEvent:(EKEvent *)event;
  32. - (void)setEndDate:(NSDate *)endDate forEvent:(EKEvent *)event;
  33. - (void)setCalendar:(EKCalendar *)calendar forEvent:(EKEvent *)event;
  34. - (void)addAlarm:(EKAlarm *)alarm forEvent:(EKEvent *)evnet;
  35. #pragma mark - 保存/删除事件
  36. - (void)saveEvent:(EKEvent *)event withCompletion:(commitResultBlk)blk;
  37. - (void)removeEvent:(EKEvent *)event withCompletion:(commitResultBlk)blk;
  38. @end