Return a Const Char* by reading an @property NSString in separate class
- by Andrew
I'm probably being an idiot here, but I cannot for the life of me find the answer that I'm looking for.
I have an array of CalEvents returned from a CalendarStore query, and for other reasons I am finding the first location of any upcoming event for today that is not an all-day or multi-day event.
+(const char*) suggestFirstiCalLocation{
CalCalendarStore *store = [CalCalendarStore defaultCalendarStore];
NSPredicate *allEventsPredicate = [CalCalendarStore eventPredicateWithStartDate:[NSDate date]
endDate:[[NSDate date] initWithTimeIntervalSinceNow:3600]
calendars:[store calendars]];
NSArray *currentEventCalendarArray = [store eventsWithPredicate:allEventsPredicate];
for (int i = 0; i< [currentEventCalendarArray count]; i++){
if (![[currentEventCalendarArray objectAtIndex:i] isAllDay]){
//Now that other events are cleared, check for multi-day
NSDate *startOnDate = [[currentEventCalendarArray objectAtIndex:i] startDate];
NSDate *endOnDate = [[currentEventCalendarArray objectAtIndex:i] endDate];
if ([endOnDate timeIntervalSinceDate:startOnDate ] < 86400.0){
NSString * iCalLocation = [[currentEventCalendarArray objectAtIndex:i] location];
return [iCalLocation UTF8String];
}
}
}
return "";
}
For other reasons, I am returning a const char with the value of the location that is found.
However, I cannot seem to return "iCalLocation" at all. The compiler fails on the line where I am initializing the "iCalLocation" variable: "Cannot convert to pointer type"
Being frank: I am new to Objective-C, and I am still trying to figure points, properties, and such out.