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?
Related
I would like to store data in the contact store that is part of CNContact. Is there a property of NSObject or CNContact that I can store the contents of a Data structure or NSDate object? I would like to be able to keep up with when a CNContact was last modified. I haven't found anything way that Apple has given us to specifically do this. I don't want to save the date of modification in UserDefaults or CloudKit or Core Data or any other way of persisting data. I don't want to use the Note property of CNContact, since it would be able to be changed by the user. The dates instance property of CNContact is get only, and I haven't found any way of using that property to do what I want to do.
An alternative would be to compare hash values or to us the .isEqual method of CNContact or use the === or == operators. Would that work?
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.
So I have an app which upon launch imports a user's specific calendar and displays all events related to it. I use NSPredicate to sort them and store the events in an array.
I would like to be able to store this array upon each launch of the app, then in another method i hope to recall it and subtract it from the same calendar events at a later time. The idea being that only the changed items will remain.
I have tried using NSUserDefaults to store the array which is about 70 items long but i get an error : Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType')
I have tried converting the array to NSData using NSKeyedArchiver but that causes a crash aswell: exception 'NSInvalidArgumentException', reason: '-[EKEvent encodeWithCoder:]
Any suggestions on how I can store and recall my events array. The reason i mention coreData in the title is i fear some of you will tell me to use that which is new to me.
Your approach is generally ok, but you're falling over at actually saving because you can't directly save an EKEvent (it isn't permissible in user defaults and it doesn't implement NSCoding).
You need to extract the parts, such as the eventIdentifier, from each EKEvent and store them in another object that you can add to user defaults (like a dictionary) or that you can archive (so it and its contents need to conform to NSCoding).
When you reload the data you would then compare each element of data you saved instead of comparing the whole EKEvents (not clear how you were doing the comparison anyway).
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.
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.