EventKit - 名为'location'的多个方法

时间:2013-10-01 03:27:58

标签: ios objective-c eventkit

我正在尝试从日历活动中列出NameLocationNotes。按预期阅读和编写NameNotes,但我遇到了“位置”字段的问题。

具体而言,以下行“meetingLocation = [element location];”会产生错误

"Multiple methods named 'location' found with mismatched result, parameter type or attributes."

这里有什么问题?代码包含在下面。

- (IBAction)reloadEvents:(id)sender {

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);

}

}

2 个答案:

答案 0 :(得分:0)

试试这个

while(element = [enumerator nextObject])
{
   EKEvent *event = element;
   meetingName = event.location;
}

答案 1 :(得分:0)

将一些旧的iOS 5转换为iOS7的类似问题:

if ([[thisEvent.recurrenceRules objectAtIndex:i] frequency] == EKRecurrenceFrequencyDaily  ){

导致

  

多种方法名称"频率"发现结果不匹配。

通过类型转换解决,然后执行if语句

EKRecurrenceRule *thisRecurranceRule = (EKRecurrenceRule *)[thisEvent.recurrenceRules objectAtIndex:i] ;
if ([thisRecurranceRule frequency] == EKRecurrenceFrequencyDaily  ){