Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)
Next, let's look at how to find a specific calendar source by type and name, first we write a Help method:
-(EKSource*)sourcesourceType:(EKSourceType)typesourceTitle:(NSString*)title{ for (EKSource *sourcein store.sources) { iftypecaseInsensitiveCompare:title] == NSOrderedSame) { returnsource; } } return nil;}
We can, of course, find it only through the title of the calendar source, but with a check on its type, it is double-insurance. We have a breakpoint at the beginning of the above method, running the app in the emulator, no accident should be interrupted at the breakpoint, we enter in the Debug console:
po store.sources
You can see the output of all the calendar sources in the simulator:
(LLDB) PO Store.Sources<__nsarrayi0x787939e0>(Eksource<0x78792770>{UUID= 705E0a9a-1FD0-4B56-b7d9-ca4e268ecf90;type = Local; Title=Default; Externalid=(NULL)},eksource<0x787939a0>{UUID=f2f63129-2812- -C0- theB8-afcefff9ac84;type =Other; Title=Other; Externalid=(NULL)})
You can see that the real name of the first calendar source in the Calendar database is default, and the next name is other. This confirms what I said in the first article, the name of the first calendar source displayed in the simulator is just an alias that is easy for the user to understand.
What if you run it in a real machine? You'll find that the first calendar source is named icloud. The difference is that the former is a local source (eksourcetypelocal), which is a remote source. Here are a few more words, the remote calendar source also has many kinds of types, such as:
EKSourceTypeExchange EKSourceTypeCalDAV
They represent two different calendar communication protocols that synchronize the calendar content on both the client and server side. Interested children shoes can self-degree Niang Valley Brother Search.
Now we can be sure that the default source in the simulator is a local source, and the icloud source is a CalDAV type of remote source.
Let's get the default and icloud sources separately, as we've analyzed above:
sourcesourcesourceTitle:@"iCloud"sourcesourcesourceTitle:@"Default"];
Three. Get the specified calendar from the calendar source
Now that we've got a calendar source, how do we get one of those calendars? The calendar in Eventkit is represented as an instance of Ekcalendar, and we also write a helper method:
type:(EKCalendarType)typeinSource:(EKSource*)sourceforEventType:(EKEntityType)eventType{ forin [source calendarsForEntityType:eventType]) { ifcasetype) { return calendar; } } return nil;}
The above code is very simple, do not need me to break up again to read.
How to create a reminder in the Calendar app that starts before any time in IOS9 (ii)