- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 OS X 上创建一个新日历。我无法在我的日历中显示日历 (newcalendar)。我运行代码,打开我的日历,但它没有显示。有谁知道为什么?这是我的 AppDelegate.swift 中的内容:
var store = EKEventStore()
// creating the new calendar
func getCalendar() -> EKCalendar? {
println("5")
let defaults = NSUserDefaults.standardUserDefaults()
if let id = defaults.stringForKey("calendarID") {
return store.calendarWithIdentifier(id)
println("6")
}
else {
var calendar = EKCalendar(forEntityType: EKEntityTypeEvent, eventStore: self.store)
println("6")
calendar.title = "newcalendar"
calendar.color = NSColor.brownColor()
calendar.source = self.store.defaultCalendarForNewEvents.source
println("7")
var error: NSError?
self.store.saveCalendar(calendar, commit: true, error: &error)
println("8")
if error == nil {
defaults.setObject(calendar.calendarIdentifier, forKey: "calendarID")
}
return calendar
println("9")
}
}
// Where it starts
func applicationDidFinishLaunching(aNotification: NSNotification) {
println("1")
var sema = dispatch_semaphore_create(0)
var hasAccess = false
// Ask for permission to access calendars
store.requestAccessToEntityType(EKEntityTypeEvent, completion: { (granted:Bool, error:NSError?) in hasAccess = granted; dispatch_semaphore_signal(sema)})
//println("Permission to connect to Calendar = \(success); error? = \(error)")
println("2")
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
println("3")
if (!hasAccess){
}
else {
// returns an array of EKCalendars
var eventCalendars =
store.calendarsForEntityType(EKEntityTypeEvent) as [EKCalendar]
println("4")
// for each calendar in array, if the calendar is called newcalendar,
for i in eventCalendars {
if i.title == "newcalendar" {
println("newcalendar already exists")
}
else {
getCalendar()
break
}
}
}
} //end of applicationDidFini...
最佳答案
requestAccessToEntityType
在不同的线程中异步运行。您需要将完成与信号量同步。我这样做:
var sema = dispatch_semaphore_create(0)
var hasAccess = false
eventStore.requestAccessToEntityType(EKEntityTypeEvent, completion: { (granted:Bool, error:NSError?) in hasAccess = granted; dispatch_semaphore_signal(sema) })
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
if (!hasAccess) {
fatalError....
}
// proceed normally
关于ios - 新的 EventKit EKCalendar 不会创建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30853099/
在我的应用程序中,我有一个开关,允许用户将某些事件放入他们的议程中。我这样处理: @IBAction func putInAgenda(_ sender: UISwitch) { le
我正在构建一个小型日历应用程序,用户可以在其中选择事件应该输入到哪个日历中。因此,用户从设置模式中的选择器 View 中选择他们选择的日历,然后当他们输入新事件时,我应该能够获取该日历对象以某种方式创
我现在开发一个显示 iCloud EKCalendar 列表的 iOS 应用程序。我的swift代码可以得到一组iCloud EKCalendars,但是顺序总是不一样。谁能给我一些建议,让我整理一下
美好的一天!我通过 UIActivityItems 使用函数“将事件保存到日历”。在该函数中,我创建了新日历并将事件添加到该日历: EKEventStore* eventStore = [[EKEve
我正在尝试使用以下方法访问新提醒的默认日历: EKCalendar.defaultCalendarForNewReminders() 此函数应返回可选的 EKCalendar ( doc page )
我是来自乌克兰的新开发者,我从 Objective-C 开始了我的道路。 我有以下问题:我创建了一个包含几个事件的 EKCalendar。我需要事件变得可重复,例如每天、每月等。 最佳答案 很高兴在我
通过使用 EventKit,我可以将事件添加到 iphone 日历,我可以使用 EkCalendar 创建一个新日历。但现在需要删除 iphone 日历中的单个事件。我怎样才能做到这一点。提前致谢 f
我在我的应用程序中使用 EventKit,想知道日历属于哪个帐户。 iPhone 日历应用程序显示所有按帐户分组的日历,帐户名称例如“myname@me.com”或“Gmail myname”。我可以
有没有办法对日历或提醒进行排序?我还没有找到 sortIndex 属性或类似的东西......提醒应用如何对项目进行排序? 最好的问候 最佳答案 目前在 iOS 6 SDK 中没有公开访问提醒应用程序
我想在我的应用程序中插入事件,以便可以在 iPhone Calendar.app 中查看它们。但由于我不想将用户事件与应用程序中的事件混合,因此我想创建一个像“MyApp Events”这样的 EKC
我正在尝试使用 EKSourceTypeLocal 创建日历来源。遍历 self.eventStore.sources , 找到带有 sourceType == .Local 的那个并尝试用它创建一个
如何更改日历的名称?我有: EKCalendar *cal; cal=[store calendarWithIdentifier:@"5F9A5BE0-03A9-4FE8-BD1E-2647F39E2
我正在尝试在 OS X 上创建一个新日历。我无法在我的日历中显示日历 (newcalendar)。我运行代码,打开我的日历,但它没有显示。有谁知道为什么?这是我的 AppDelegate.swift
我想在 iOS 上创建订阅日历,但将其存储在 iCloud 中,以便在用户的其他设备上可见。我看到了如何创建 iCloud EKCalendar,但我看不到任何方式来告诉它订阅的 url 是什么。 这
我有一个应用程序,我想在其中安排一些事件。所以我想为我的应用程序创建一个新日历,如果它尚不存在并且它在添加新事件时确实引用了它。 最佳答案 这是在 iOS 5 上使用 EventKit 框架完成的:
我在创建 EKCalendar 时遇到问题,一切看起来都不错,但当我去列出我的日历时,它没有显示。我还去查看我的日历应用程序中的日历列表,但它不存在。有什么想法吗? 这是我用于创建日历的按钮代码: -
我有一个 NSArray,里面有一堆 EKCalendar 对象。我需要按字母顺序对它们进行排序。我是选择器的新手,但我想我需要类似的东西...... NSArray *array = [otherA
当我的应用程序首次运行时,我试图在 EKEventStore 中创建一个日历。我找到了 this tutorial但我对 Objective-C 的了解还不够多,无法将其转换为 Swift,而且根据我
我遵循了这个答案:how do I create a new EKCalendar on iOS device? 但是我创建的日历没有出现在 iPhone 的 calendar.app 中?应该吗?
给定任何 EKCalendar,我如何检查这个日历是否是 Facebook 日历? Facebook 日历可以是 Facebook 事件日历或 Facebook 生日日历。 最佳答案 不幸的是,如果不
我是一名优秀的程序员,十分优秀!