Question

I am trying to list out the Name, Location, and Notes from calendar events. Reading and writing the Name and Notes work as expected but I run into problems with the Location field.

Specifically, the following line "meetingLocation = [element location];" produces the error

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

What is wrong here? Code is included below.

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

}

}

Was it helpful?

Solution

Try like this

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

OTHER TIPS

Similar problem converting some old iOS 5 to iOS7:

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

resulted in

Multiple methods names "frequency" found with mismatched result.

Resolved by typecasting and then doing the if statement

EKRecurrenceRule *thisRecurranceRule = (EKRecurrenceRule *)[thisEvent.recurrenceRules objectAtIndex:i] ;
if ([thisRecurranceRule frequency] == EKRecurrenceFrequencyDaily  ){
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top