[英]Swift issue with Attendees, unable to get name, email, etc…I keep getting error message
I tried to fetching calendar, I have no problem with title, color, start/end date, etc...but I decision to add "Invited" but I keep getting error said:我试图获取日历,我对标题、颜色、开始/结束日期等没有任何问题……但我决定添加“邀请”,但我不断收到错误消息:
For-in loop requires '[EKParticipant]?' to conform to 'Sequence'; did you mean to unwrap optional?
Here my codes:这是我的代码:
func create_currentevent_date() {
let endtime = Calendar.current.date(bySettingHour: 23, minute: 59, second: 59, of: Date())!
for get_category in date_calendar_category_user {
for search_category in eventStore.calendars(for: EKEntityType.event) {
if search_category.title == get_category {
for get_event in eventStore.events(matching: eventStore.predicateForEvents(withStart: Date(), end: endtime, calendars: [search_category])) {
let event_start = get_event.startDate.timeIntervalSince1970
let event_end = get_event.endDate.timeIntervalSince1970
let time_rightnow = Date().timeIntervalSince1970
for get_invite_detail in get_event.attendees { //THIS IS WHERE I GET ERROR MESSAGE
}
if time_rightnow >= event_start && time_rightnow <= event_end {
date_calendar_currentevent.append(calendar_getdetail(ce_title: get_event.title,
ce_category: get_event.calendar.title,
ce_color: get_event.calendar.cgColor,
ce_invited_name: "",
ce_invited_email: "",
ce_start: get_event.startDate,
ce_end: get_event.endDate))
}
}
}
}
}
for get_detal in date_calendar_currentevent {
print("\(get_detal.ce_invited_name) and \(get_detal.ce_invited_email)")
}
}
I want to get name/email (for now) from attendees into the string.我想从与会者那里获取姓名/电子邮件(暂时)到字符串中。 How can I do that?
我怎样才能做到这一点?
Thank you谢谢
unwrap the optional get_event.attendees before looping through it在循环之前解开可选的 get_event.attendees
if let attendees = get_event.attendees {
for attendee in attendees {
// do your code here
print(attendee.name ?? "")
}
}
https://developer.apple.com/documentation/eventkit/ekparticipant https://developer.apple.com/documentation/eventkit/ekparticipant
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.