Ios EventKit-名为“location”的多个方法
我试图列出日历事件中的名称、位置和注释。读写名称和注释的工作与预期的一样,但我遇到了位置字段的问题 具体来说,以下行meetingLocation=[元素位置];产生错误Ios EventKit-名为“location”的多个方法,ios,objective-c,eventkit,Ios,Objective C,Eventkit,我试图列出日历事件中的名称、位置和注释。读写名称和注释的工作与预期的一样,但我遇到了位置字段的问题 具体来说,以下行meetingLocation=[元素位置];产生错误 "Multiple methods named 'location' found with mismatched result, parameter type or attributes." 这里怎么了?代码包括在下面 -IBActionreloadEvents:idsender{ NSString *meetingName
"Multiple methods named 'location' found with mismatched result, parameter type or attributes."
这里怎么了?代码包括在下面
-IBActionreloadEvents:idsender{
NSString *meetingName;
NSString *meetingLocation;
NSString *meetingNotes;
// Define a range of event dates we want to display
NSDate *startDate = [NSDate dateWithTimeIntervalSinceNow:(-1*60*60*.5)]; // .5 hour in the past
NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:(60*60*24*1)]; // 1 day from now
//NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:(60*60*24*7)]; // 7 days from now
// Create a predicate to search all celndars with our date range using the start date/time of the event
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:nil];
// Query the event store using the predicate.
NSArray *results = [self.eventStore eventsMatchingPredicate:predicate];
// Convert the results to a mutable array and store so we can implement swipe to delete
//NSMutableArray *events = [[NSMutableArray alloc] initWithArray:results];
//self.events = events;
NSEnumerator * enumerator = [results objectEnumerator];
id element;
while(element = [enumerator nextObject])
{
// Set the meeting name
meetingName = [element title];
NSLog(@"Name=%@",meetingName);
// Set the meeting location
meetingLocation = [element location];
NSLog(@"Location=%@",meetingLocation);
// Set the meeting notes
meetingNotes = [element notes];
NSLog(@"Notes=%@",meetingNotes);
}
}像这样试试
while(element = [enumerator nextObject])
{
EKEvent *event = element;
meetingName = event.location;
}
将某些旧iOS 5转换为iOS 7时出现类似问题:
if ([[thisEvent.recurrenceRules objectAtIndex:i] frequency] == EKRecurrenceFrequencyDaily ){
导致
发现多个方法名称,但结果不匹配
通过类型转换然后执行if语句来解决
EKRecurrenceRule *thisRecurranceRule = (EKRecurrenceRule *)[thisEvent.recurrenceRules objectAtIndex:i] ;
if ([thisRecurranceRule frequency] == EKRecurrenceFrequencyDaily ){