Adding EKParticipants to an EKEvent - ios

I'd like to programatically add a participant to an EKEvent on iOS.
EKParticipant's class reference states "You do not create EKParticipant objects directly. Send attendees to an EKEvent object to get an array of EKParticipant objects.".
EKEvent's class reference states that the 'attendees' member (NSArray) is "The attendees associated with the event, as an array of EKParticipant objects. (read-only)"

Not possible. This is done deliberately by Apple so only the user can create or edit meetings' invitees. The only way is to display a EKEventEditViewController and let the user edit the list themselves.
You can delve into private API, but you risk a 99% app store validation failure.

Related

Adding a unique identifier to EKEvent

In my app I'm creating an EKEvent to mark an appointment I make from server data, and then I add it to the phone's main calendar.
Doing that, I would like to save the appointment's Id in the calendar so that I can fetch it easily.
While exploring the EKEvent object, I found the eventIdentifier property, but it is readOnly so I cannot assign value to it.
Is there a way to add custom properties (like Id) to an EKEvent?

Mixpanel UUID Retrieving

I have to retrieve UUID of user from mix panel, The expected scenario, need to append inviter UUID to their invited user events.
And how to perform increment feature for people properties in mix panel?
Mixpanel's unique identifier is called distinct_id.User can be identified by its Unique identifier as well using "distinctId" property you can retrieve user's identifier.
Mixpanel *mixpanel = [Mixpanel sharedInstanceWithToken:#"Token"];
[mixpanel identify:mixpanel.distinctId];
Same way we can access .distinctId property to retrive user details.
People property increments with no of people follow the same event.
[mixpanel.people increment:#"Event Name" by:[NSNumber numberWithInt:1]];

Store custom objects in UILocalNotification's userInfo without encoding

I have a custom class called Person that I want to store in UILocalNotification's userInfo (NSDictionary).
Is there any way to save it without converting it to NSData object using -encodeWithCoder:?
One simple workaround is to give every person a unique id and store the id in userInfo.
Save an instance of person and fetch it with the id whenever you need to get the userInfo
The userInfo dictionary has some limitations exposed here.
So I think, you need to serialize the Person object to be able to store it in that location.

calendarsForEntityType return empty array

I am experiencing a weird behaviour by the EKEventStore.
Started the app and didn't allow access to my Calendars.
Obviously I couldn't approach my Calendars as "Granted = NO"...
Killed the app.
Went to settings and enabled access to Calendars.
Ran the app again, now I get "Granted = YES" but [self.store calendarsForEntityType:EKEntityTypeEvent] returns an empty array.
I've made sure self.store is not nil and that I do have Calendars objects in my Calendars. What else could it be?
The issue obviously is in your self.store, how do you construct it ?
Based on the documentation you have to retrieve the sources property of EKEventStore object, which is an array of EKSource type, on which you can call calendarsForEntityType
An instance of the EKSource class represents the account that a
calendar belongs to. You do not create instances of this class. You
retrieve EKSource objects from an EKEventStore object. Use the sources
property to get all the EKSource objects for an event store, and use
the methods in this class to access properties of the source object.

Sending NSNotifications to all objects of a class

I have an object that can be selected by a user click. With the current requirements of the app, at any time, there is no more than one of these items selected at any point during app execution.
I implemented a mechanism to enforce this, as follows:
Each of these objects has a unique identifier as a property.
When each object is created, it subscribes to the NSNotificationCenter listening for the MY_OBJECT_SELECTED notification.
When each object is selected, it posts the MY_OBJECT_SELECTED notification, with its unique Id as part of the userInfo dictionary.
Then, when each object receives the notification, it checks to see if its id is the same as the one in the userInfo. If it is, it does nothing, but if it isn't, it sets itself to unselected.
Is this a decent approach to the problem? If not, how would you do it?
It is a decent way of doing it, although it is not very efficient. The more objects you have, the more time you spend comparing IDs. The easiest way is to store your object pointers and IDs in a map table (or similar) and remember the last selected object. Whenever you select a new object, you clear the selection flag of the last selected object, then look up the new object and set its selection flag. It requires you to keep a collection of your objects, though.
The time required to update selections with this approach is independent of the number of objects you have.
If the object is spread all over the app,i.e. if it is a member in various classes. You can have a global object of same type and assign it to only that object which has been touched. In steps it will be like:
Have a global variable of object type.
At any object touch assign globalObject = currentObject;
do all operations on globalObject throughout app like calling methods and modifying object members(have a check for nil to ensure safety).
Reassign to different object with new touch.

Resources