我试图从日历事件中列出Name
、Location
和Notes
。Name
和Notes
按预期的方式读写,但我在Location字段中遇到了问题。
具体来说,下面的"meetingLocation = [element location];
“行会产生错误
"Multiple methods named 'location' found with mismatched result, parameter type or attributes."
这里怎么了?代码包括在下面。
-(IBAction)reloadEvents:(Id)发件人{
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);
}
}
发布于 2013-09-30 20:12:17
试着像这样
while(element = [enumerator nextObject])
{
EKEvent *event = element;
meetingName = event.location;
}
发布于 2014-04-06 02:16:18
类似的问题是将一些旧的iOS 5转换为iOS7:
if ([[thisEvent.recurrenceRules objectAtIndex:i] frequency] == EKRecurrenceFrequencyDaily ){
结果是
多个方法名为“频率”,结果不匹配。
通过类型转换然后执行if语句来解析
EKRecurrenceRule *thisRecurranceRule = (EKRecurrenceRule *)[thisEvent.recurrenceRules objectAtIndex:i] ;
if ([thisRecurranceRule frequency] == EKRecurrenceFrequencyDaily ){
https://stackoverflow.com/questions/19107440
复制相似问题