So, I would like to read in my array of events from a calendar I am subscribed to. The events all have a similar format, for example with two modules, 'Meaning of Life' and 'Running long distances':
所以,我想从我订阅的日历中读取我的一系列事件。这些事件都有类似的格式,例如有两个模块,“生命的意义”和“长距离跑”:
Talk: Meaning of Life
谈话:生命的意义
Talk: Running long distances
谈话:长跑
Talk: Meaning of Life
谈话:生命的意义
Talk: Meaning of Life
谈话:生命的意义
Talk: Running long distances
谈话:长跑
I would like to be able to use something like
我希望能够使用类似的东西
[[event.title componentsSeparatedByString:@"Talk: "] objectAtIndex:i];
So that in my table view I can have a 'Meaning of life' cell and a 'Running long distances' one. The idea would then be to select one and you could see all the 'Talks' for that module. There are other categories too like 'Workshops' and 'Practicals'.
因此,在我的表格视图中,我可以拥有“生命意义”单元格和“长距离跑步”单元格。然后我们的想法是选择一个,你可以看到该模块的所有“谈话”。还有其他类别,如'工作坊'和'实用'。
Currently my code to just display all the events is as follows (ignoring the getting events of selected calendar and producing an array titled arrEvents)
目前我只显示所有事件的代码如下(忽略所选日历的获取事件并生成一个名为arrEvents的数组)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableIDCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TableIDCell"];
}
// Get each single event.
EKEvent *event = [self.arrEvents objectAtIndex:indexPath.row];
// Set its title to the cell's text label.
cell.textLabel.text = event.title;
// Get the event start date as a string value.
NSString *startDateString = [self.appDelegate.eventManager getStringFromDate:event.startDate];
// Get the event end date as a string value.
NSString *endDateString = [self.appDelegate.eventManager getStringFromDate:event.endDate];
// Add the start and end date strings to the detail text label.
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ - %@", startDateString, endDateString];
if (indexPath.row%2 == 0) {
UIColor *altCellColor = [UIColor colorWithWhite:0.7 alpha:0.1];
cell.backgroundColor = altCellColor;
}
return cell;
}
Thanks for taking the time to read :)
感谢您花时间阅读:)
1 个解决方案
#1
0
I sorted it in the end by modifying the arrEvents in the class where it is generated. I was able to check if it contained string "Talk: " and them remove that bit and also check if arrEvents already contained a title and then not to add duplicates.
我最后通过修改生成它的类中的arrEvents对它进行了排序。我能够检查它是否包含字符串“Talk:”并删除该位,并检查arrEvents是否已包含标题,然后不添加重复项。
#1
0
I sorted it in the end by modifying the arrEvents in the class where it is generated. I was able to check if it contained string "Talk: " and them remove that bit and also check if arrEvents already contained a title and then not to add duplicates.
我最后通过修改生成它的类中的arrEvents对它进行了排序。我能够检查它是否包含字符串“Talk:”并删除该位,并检查arrEvents是否已包含标题,然后不添加重复项。