iOS Question Problem SetField Invitees

mayahandayani

Member
Licensed User
Hello!
I have problem when I want to set some emails as invitees using EventKit (https://developer.apple.com/documentation/eventkit/ekparticipant?language=objc).
This is my code :
B4X:
Dim ev As CalendarEvent = store.CreateEvent
Dim newEvent As NativeObject = ev

Dim attendee As NativeObject
attendee.Initialize("EKParticipant")
Dim url As NativeObject
url.Initialize("NSURL")
url = url.RunMethod("URLWithString:", Array("mailto:" & "[email protected]"))
Dim attend As List
attend.Initialize
attend.Add(url)
attendee.SetField("URL", attend)       
newEvent.SetField("attendees", Array(attendee))

and I've got error like this
B4X:
[<EKParticipant 0x1f64fca80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key URL.

what's wrong?
thanks
 
Last edited:

mayahandayani

Member
Licensed User
Please post the link to the property documentation that you want to set. If it is a field that you see with the debugger and it isn't documented then you will not be able to call it.

I'm using EKParticipant but I have no idea how to set the email as invitees. Or what the property I can use and how to set it?

Thanks
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Looks like you are using the wrong object.

from the documentation

Overview

Do not create EKParticipant objects directly. Instead, use the property attendees on EKCalendarItem to return an array of EKParticipant objects.

EventKit cannot add participants to an event nor change participant information. Use the properties in this class to get information about a participant.

A participant can be a person, group, room, or other resource.
 
Upvote 0

mayahandayani

Member
Licensed User
I don't understand what you mean by "set the email as invitees"
like this on iPhone Calendar
IMG_0019-min.jpg
 
Upvote 0

mayahandayani

Member
Licensed User
StackOverflow seems to have a solution.

like this?
B4X:
Dim attendees As List
attendees.Initialize
Dim attendee As NativeObject
attendee.Initialize("EKAttendee")
attendee.SetField("emailAddress", "[email protected]")
attendees.Add(attendee)
newEvent.SetField("attendees", attendees)
but still same error
 
Upvote 0
Top