iOS12 中的 EKCalendar 标题为空白
EKCalendar title in iOS12 is blank
在 iOS 12 中,我正在尝试列出日历。我可以打印日历 ID,但标题都是空白的。我做错了什么?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let status = EKEventStore.authorizationStatus(for: EKEntityType.event)
switch (status) {
case EKAuthorizationStatus.notDetermined:
EKEventStore().requestAccess(to: .event, completion: {
(granted: Bool, error: Error?) in
if granted != true {
print("Access not granted")
}
})
case EKAuthorizationStatus.authorized:
print("Access granted")
case EKAuthorizationStatus.restricted, EKAuthorizationStatus.denied:
print("Access restricted or denied")
}
print("Calendars:")
for c in EKEventStore().calendars(for: EKEntityType.event) {
print(" \(c.calendarIdentifier):\(c.title)")
}
}
我不确定为什么,但这段代码显示了 iOS 12 模拟器中的事件标题。
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let status = EKEventStore.authorizationStatus(for: EKEntityType.event)
let eventStore = EKEventStore() //<-
switch (status) {
case EKAuthorizationStatus.notDetermined:
eventStore.requestAccess(to: .event, completion: {
(granted: Bool, error: Error?) in
if granted != true {
print("Access not granted")
}
})
case EKAuthorizationStatus.authorized:
print("Access granted")
case EKAuthorizationStatus.restricted, EKAuthorizationStatus.denied:
print("Access restricted or denied")
}
print("Calendars:")
for c in eventStore.calendars(for: EKEntityType.event) {
print(" \(c.calendarIdentifier):\(c.title)",c)
}
}
也许,您需要在访问 EKCalendar
属性时保持对 EKEventStore
实例的强引用。
在 iOS 12 中,我正在尝试列出日历。我可以打印日历 ID,但标题都是空白的。我做错了什么?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let status = EKEventStore.authorizationStatus(for: EKEntityType.event)
switch (status) {
case EKAuthorizationStatus.notDetermined:
EKEventStore().requestAccess(to: .event, completion: {
(granted: Bool, error: Error?) in
if granted != true {
print("Access not granted")
}
})
case EKAuthorizationStatus.authorized:
print("Access granted")
case EKAuthorizationStatus.restricted, EKAuthorizationStatus.denied:
print("Access restricted or denied")
}
print("Calendars:")
for c in EKEventStore().calendars(for: EKEntityType.event) {
print(" \(c.calendarIdentifier):\(c.title)")
}
}
我不确定为什么,但这段代码显示了 iOS 12 模拟器中的事件标题。
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let status = EKEventStore.authorizationStatus(for: EKEntityType.event)
let eventStore = EKEventStore() //<-
switch (status) {
case EKAuthorizationStatus.notDetermined:
eventStore.requestAccess(to: .event, completion: {
(granted: Bool, error: Error?) in
if granted != true {
print("Access not granted")
}
})
case EKAuthorizationStatus.authorized:
print("Access granted")
case EKAuthorizationStatus.restricted, EKAuthorizationStatus.denied:
print("Access restricted or denied")
}
print("Calendars:")
for c in eventStore.calendars(for: EKEntityType.event) {
print(" \(c.calendarIdentifier):\(c.title)",c)
}
}
也许,您需要在访问 EKCalendar
属性时保持对 EKEventStore
实例的强引用。