ios - 如何以编程方式调用实例变量

标签 ios uievent

目标是通过 Apple's documentation 创建提醒事件。到目前为止,我已经创建了实例变量(也在头文件中实现了)。

- (EKReminder *)reminderWithEventStore:(EKEventStore *)eventStore {

    EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
    event.title     = webTitle;
    event.notes     = urlField.text;

    event.startDate = [[NSDate alloc] init];
    event.endDate   = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];

    [event setCalendar:[eventStore defaultCalendarForNewEvents]];
    NSError *err;
    [eventStore saveEvent:event span:EKSpanThisEvent error:&err];
}

如何通过单击 UIActionSheet 中的按钮时执行代码来创建提醒?我已经尝试过 [self.eventStore:self]; 但我猜它不仅仅如此。

最佳答案

此处您只是将事件添加到默认日历中。一旦您调用此函数,事件就会被添加。

只需创建一个 EKEventStore 对象

EKEventStore *eventStore = [[EKEventStore alloc] init];

并调用你的函数:-

[self reminderWithEventStore:eventStore];

但是您不会在非 void 函数中返回任何内容:),但是,该函数定义已记录在 iOS API 版本 6 中的 EKReminder Apple 中。 ,这是一个类方法。

+ (EKReminder *)reminderWithEventStore:(EKEventStore *)eventStore

您是否尝试覆盖上述方法。

您可以使用上面的类方法简单地在日历中添加提醒。

首先你要明确自己的动机,是否要添加

1 个事件

2 提醒

3 日历。

关于ios - 如何以编程方式调用实例变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15460540/

相关文章:

ios - 如何在不创建 *Cell.swift 文件的情况下访问 UITableViewCell 对象

ios - 如何将 stackViews 添加到 UITableViewCell?

ios - 如何在 Swift 中将文件写入位于 Apple 的文件应用程序中的文件夹

ios - 为什么当我暂停 AVAudioPlayer 时锁屏音频控件会消失?

ios - 获取 UIView 上的最后一个触摸事件

iphone - 拦截 UIEvents 并将它们传递给父元素

swift - iOS 响应链和事件

ios - 来自 Google 的 Apple Maps 转换

ios - 企业应用单应用模式并不总是自动启动